diff options
| author | saltycrys <73420320+saltycrys@users.noreply.github.com> | 2020-12-13 10:16:26 +0100 |
|---|---|---|
| committer | saltycrys <73420320+saltycrys@users.noreply.github.com> | 2020-12-19 18:37:30 +0100 |
| commit | eea7ca9b72ac71560900b8d744287a97ac23c4eb (patch) | |
| tree | 9b41eb31fe2b5f4d866d62c332b7908f405d1758 /assets | |
| parent | c7c732ebc0f4b1b1847b2e0b6442e971845d9fbd (diff) | |
| download | invidious-eea7ca9b72ac71560900b8d744287a97ac23c4eb.tar.gz invidious-eea7ca9b72ac71560900b8d744287a97ac23c4eb.tar.bz2 invidious-eea7ca9b72ac71560900b8d744287a97ac23c4eb.zip | |
Add DASH quality preference
The options are `auto` (the current and default behavior), `best` and `worst`.
The UI is only updated once playback starts.
Diffstat (limited to 'assets')
| -rw-r--r-- | assets/js/player.js | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/assets/js/player.js b/assets/js/player.js index a6b35d35..930680d6 100644 --- a/assets/js/player.js +++ b/assets/js/player.js @@ -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); +} |
