Skip to content

Caching Assets

In this example we will show you how you can use the UI Builder Studio API to manually cache assets on the playout engines.

This can be usefull, for example, if you need to prepare assets for playout from a custom Show or Template UI.

Cache Assets using UI Builder Studio API

We will use the UI Builder Studio API to cache a MediaHub asset on every engine of the current PROGRAM channel.

1
2
// We simply call the following code and specify the directory of the file we want to Cache
Api.profile.program.cache('mediahub:///Path/To/MediaHub/Asset.png')

The full signature is cache(assets, verify?):

  • assets may be a single path or an array of paths.
  • verify set to true forces Erizos Studio to re-verify the file already in the cache instead of trusting it.
1
2
// Cache several assets at once, and verify them against the source
Api.profile.program.cache(['mediahub:///A.png', 'mediahub:///B.png'], true)

Tip

The pathway to the assets must precisely match the way Erizos Studio caches them. You can locate this pathway in the logs.

Other targets

Api.profile.program is the PROGRAM channel of the active profile. The same call is available on the other targets:

1
2
3
4
5
6
7
8
// The PREVIEW channel of the active profile
Api.profile.preview.cache('mediahub:///Path/To/MediaHub/Asset.png')

// A named channel of a named profile
Api.profile('MyProfile').channel('MyChannel').cache('mediahub:///Path/To/MediaHub/Asset.png')

// A single engine, by its id
Api.engine(engineId).cache(['mediahub:///A.png', 'mediahub:///B.png'], true)

Info

Every one of these calls is asynchronous and returns a promise.