Add DASH quality preference

The options are `auto` (the current and default behavior), `best` and `worst`.

The UI is only updated once playback starts.
This commit is contained in:
saltycrys 2020-12-13 10:16:26 +01:00
parent c7c732ebc0
commit eea7ca9b72
6 changed files with 38 additions and 1 deletions

View file

@ -154,6 +154,18 @@ if (video_data.params.autoplay) {
if (!video_data.params.listen && video_data.params.quality === 'dash') {
player.httpSourceSelector();
if (video_data.params.quality_dash != "auto") {
player.ready(() => {
player.on("loadedmetadata", () => {
const qualityLevels = Array.from(player.qualityLevels()).sort((a, b) => a.height - b.height);
const targetQualityLevel = video_data.params.quality_dash == "best" ? qualityLevels.length - 1 : 0;
for (let i = 0; i < qualityLevels.length; i++) {
qualityLevels[i].enabled = (i == targetQualityLevel)
}
});
});
}
}
player.vttThumbnails({
@ -510,4 +522,6 @@ window.addEventListener('keydown', e => {
}());
// Since videojs-share can sometimes be blocked, we defer it until last
player.share(shareOptions);
if (player.share) {
player.share(shareOptions);
}