Load control
When adding a source, we can define its load control to the options - defining what source should be loading (default is Data
).
Load control takes following values
- 0 - Nothing
- 1 - Metadata (Loading of the manifests)
- 2 - Data (Loading of the manifests and segments)
const player = bitmovin.playerx.Player({
key: 'YOUR-PLAYER-KEY',
defaultContainer: document.getElementById("player-container")
});
const firstSourceConfig = {
resources: [{
url: 'https://cdn.bitmovin.com/content/assets/streams-sample-video/tos/m3u8/index.m3u8',
}]
}
const firstSourceApi = player.sources.add(firstSourceConfig, { loadControl: 1 });
In sample above, the source will only load manifests, and will not load any segments. We can use this in combination with attach to add assets we want to preload manifests, but not segments.
const firstSourceConfig = {
resources: [{
url: 'https://cdn.bitmovin.com/content/assets/streams-sample-video/tos/m3u8/index.m3u8',
}]
}
const secondSourceConfig = {
resources: [{
url: 'https://cdn.bitmovin.com/content/assets/streams-sample-video/sintel/m3u8/index.m3u8'
}]
}
const firstSourceApi = player.sources.add(firstSourceConfig`);
const secondSourceApi = player.sources.add(secondSourceConfig, { attached: false, loadControl: 1 }`);
In this case, we have one active source (first source) that has video element and can play. While second source is just loading manifests in the background.
We are able at any point of time to make second source load segments, and to set a video element to it.
const firstSourceApi = player.sources.add(firstSourceConfig`);
const secondSourceApi = player.sources.add(secondSourceConfig, { attached: false, loadControl: 1 }`);
secondSourceApi.loadControl = 2;
player.sources.attachVideo(secondSourceApi)
Updated 5 months ago