diff options
author | James Taylor <user234683@users.noreply.github.com> | 2021-08-25 14:47:57 -0700 |
---|---|---|
committer | Jesús <heckyel@hyperbola.info> | 2021-08-29 21:47:14 -0500 |
commit | 9f44e0474be03e1a7d616db092293df0c0e496a3 (patch) | |
tree | 002e89e35d809d3fc46b37d272fd2b400e677851 /youtube/templates/watch.html | |
parent | ee581c56a3676936110bbcca8bc755f5adb59b6d (diff) | |
download | yt-local-9f44e0474be03e1a7d616db092293df0c0e496a3.tar.lz yt-local-9f44e0474be03e1a7d616db092293df0c0e496a3.tar.xz yt-local-9f44e0474be03e1a7d616db092293df0c0e496a3.zip |
Integrate quality selection into Plyr
Signed-off-by: Jesús <heckyel@hyperbola.info>
Diffstat (limited to 'youtube/templates/watch.html')
-rw-r--r-- | youtube/templates/watch.html | 54 |
1 files changed, 26 insertions, 28 deletions
diff --git a/youtube/templates/watch.html b/youtube/templates/watch.html index 912237a..450ba60 100644 --- a/youtube/templates/watch.html +++ b/youtube/templates/watch.html @@ -56,6 +56,30 @@ </figure> <script src="/youtube.com/static/js/av-merge.js"></script> + <script> + function changeQuality(selection) { + var video = document.getElementById('js-video-player'); + var currentVideoTime = video.currentTime; + var videoPaused = video.paused; + var videoSpeed = video.playbackRate; + var videoSource; + if (avMerge) + avMerge.close(); + if (selection.type == 'uni'){ + videoSource = data['uni_sources'][selection.index]; + video.src = videoSource.url; + } else { + let srcPair = data['pair_sources'][selection.index]; + videoSource = srcPair[0]; + avInitialize(video, srcPair, currentVideoTime); + } + video.currentTime = currentVideoTime; + if (!videoPaused){ + video.play(); + } + video.playbackRate = videoSpeed; + } + </script> {% if using_pair_sources %} <!-- Initialize av-merge --> <script> @@ -104,7 +128,7 @@ <script src="/youtube.com/static/js/speedyplay.js"></script> <select id="quality-select"> {% for src in uni_sources %} - <option value='{"type": "uni", "index": {{ loop.index0 }}}' {{ 'selected' if loop.index0 == uni_idx and not using_pair_sources else '' }} >{{ src['quality_string'] }} (integrated)</option> + <option value='{"type": "uni", "index": {{ loop.index0 }}}' {{ 'selected' if loop.index0 == uni_idx and not using_pair_sources else '' }} >{{ src['quality_string'] }}</option> {% endfor %} {% for src_pair in pair_sources %} <option value='{"type": "pair", "index": {{ loop.index0}}}' {{ 'selected' if loop.index0 == pair_idx and using_pair_sources else '' }} >{{ src_pair[0]['quality_string'] }}, {{ src_pair[1]['quality_string'] }}</option> @@ -113,28 +137,7 @@ <script> document.getElementById('quality-select').addEventListener( 'change', function(e) { - var video = document.getElementById('js-video-player'); - var selection = JSON.parse(this.value); - var currentVideoTime = video.currentTime; - var videoPaused = video.paused; - var videoSpeed = video.playbackRate; - var videoSource; - if (avMerge) - avMerge.close(); - if (selection.type == 'uni'){ - videoSource = data['uni_sources'][selection.index]; - video.src = videoSource.url; - } else { - let srcPair = data['pair_sources'][selection.index]; - videoSource = srcPair[0]; - avInitialize(video, srcPair, currentVideoTime); - } - setVideoDimensions(videoSource.height, videoSource.width); - video.currentTime = currentVideoTime; - if (!videoPaused){ - video.play(); - } - video.playbackRate = videoSpeed; + changeQuality(JSON.parse(this.value)) } ); </script> @@ -445,11 +448,6 @@ </div> - <script> - // @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPL-v3-or-Later - data = {{ js_data|tojson }}; - // @license-end - </script> <script src="/youtube.com/static/js/common.js"></script> <script src="/youtube.com/static/js/transcript-table.js"></script> {% if settings.use_video_player == 2 %} |