Getting Started with Custom Adaptation
The player provides two new events: onVideoAdaptation and onAudioAdaptation. It can be used to "overwrite" a suggested representation with any other. This can be used to create a custom adaptation logic.
A sample implementation is available in /howto/js/PreferredStartupQuality.js adaptation folder of this package. It uses a preferred startup quality and searches for the representation equal to or lower than the startup quality. It uses this or a higher quality (if suggested by the player's internal logic) for a specified amount of time. It can be used as follows:
var player = bitdash('myVideoDiv');
player.setup(conf);
var startupQuality = new PreferredStartupQuality(player, 1000000, 10);
The first parameter is the player object. The second is the preferred quality in bits per seconds and is optional. It defaults to 1mbps. The third, also optional, specifies how long the startup phase lasts, in seconds.
In addition, it's recommended to set a higher startup threshold than using the default adaptation logic. This is the number of seconds of data which has to be buffered on the client before playback begins. For the PreferredStartupQuality provided, e.g. 5 seconds works for better but also for poorer bandwidth quite good:
var config = {
...
tweaks: {
startup_threshold: 5
}
}