Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions youtube/templates/watch.html
Original file line number Diff line number Diff line change
Expand Up @@ -678,6 +678,23 @@ <h2 class="title">{{ title }}</h2>

<script src="/youtube.com/static/js/av-merge.js"></script>
<script src="/youtube.com/static/js/watch.js"></script>
<script>
var video = document.querySelector('video.video'),
fps_selector = document.querySelector('#quality-select'),

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This element isn't available when Plyr is being used

fps_int = parseInt(fps_selector.options[fps_selector.selectedIndex].text.split("p")[1].slice(0,2)),

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Preferable to get this information from the javascript, not by reading from html text on the page, as this string may change. Also, this will error out if it fails to get the fps. The fps could be missing due to YouTube not providing it

frameTime = 1 / fps_int;
fps_selector.onchange=function(){
fps_int = parseInt(fps_selector.options[fps_selector.selectedIndex].text.split("p")[1].slice(0,2)),
frameTime = 1 / fps_int;
}
window.addEventListener('keypress', function (evt) {
if (evt.keyCode === 44) {
video.currentTime = Math.max(0, video.currentTime - frameTime);
} else if (evt.keyCode === 46) {
video.currentTime = Math.min(video.duration, video.currentTime + frameTime);
}
});
</script>
{% if settings.video_player == 1 %}
<!-- plyr -->
<script>var storyboard_url = {{ storyboard_url | tojson }}</script>
Expand Down