Simple playback
Using the sources api for adding a source is straight forward. And for this we can use the default behaviour of the player - where when ever the source is added, it is automatically attached and is the active one.
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',
type: 'hls',
}]
}
const firstSourceApi = player.sources.add(firstSourceConfig);
firstSourceApi.play();
Every resource requires atypeAs of version
10.2.0, each resource inresourcesmust declare atype. The player uses it to route the resource to the matching streaming technology. Valid values are'hls','dash'and'progressive'. See Resource types for details.
We are now able to use firstSourceApi (source/playback api) to control that source. Read more about available methods in SourceAPI in here.
If you want to learn how to add multiple sources, and control their load control, please checkout page about adding multiple sources.