Configuration
You can optionally provide a variety of configuration settings whereby it is possible to fine-tune the behaviour of the player engine. Previously the SDK required your choice of settings to be applied and re-applied after a new source stream has been set. The SDK can now retain configuration settings over a zap, removing the need for complexity in your code. However, this is still possible if a new configuration is required for the new stream.
Setting configuration parameters
Use of the configure()
API is only relevant for DASH streams; it does not affect Safari.
The OtvToolkit provides a general purpose configure()
API which allows a huge range of adjustments to be made.
This can be used in two different ways, where:
A parameter and its value are passed as an argument pair.
JSplayerInstance .otvtoolkit() .configure(<string parameter>, <value>);
A JavaScript Object carrying the structure of one or many parameters and their values.
JSplayerInstance .otvtoolkit() .configure(<object parameter>);
For example, the following calls to the API would be equivalent:
playerInstance
.otvtoolkit()
.configure("abr.restrictions.minBandwidth", 200);
playerInstance
.otvtoolkit()
.configure({
abr:{
restrictions:{
minBandwidth: 200
}
}
});
For more details on the underlying Shaka Player API that the configure()
API models, see https://shaka-player-demo.appspot.com/docs/api/shaka.Player.html#configure
Other configuration capabilities
Bitrate/Resolution capping
See Resolution and bitrate capping where other configuration APIs for specific purposes are described.
Segment download resiliency
See DASH segment download resiliency for other examples of possible configuration options.
Preferred Audio Language
See Multi-audio.
Preferred Subtitle Language
See Subtitles.
Reading back the configuration
The OtvToolkit provides a corresponding getConfiguration()
API, which allows all of the currently applied configuration settings to be retrieved.
playerInstance
.otvtoolkit()
.getConfiguration();
Before initial playback, this will return an empty JavaScript object ({}
). Once initial playback has happened, this will return a much more detailed object.
If you only were interested in a sub-section of the various parameters, you can always suffix this with the relevant sub-section(s) hierarchy, for example:
let currentConfig = playerInstance
.otvtoolkit()
.getConfiguration().abr.restrictions;
console.log(currentConfig);
{minWidth: 0, maxWidth: Infinity, minHeight: 0, maxHeight: 720, minPixels: 0, …}