From 3398a9fe6b8c3598a30d4571cab4aa76fa275bff Mon Sep 17 00:00:00 2001 From: Omar Roth Date: Fri, 3 Aug 2018 19:51:29 -0500 Subject: [PATCH] Move player options into initialization --- src/invidious/views/embed.ecr | 78 +++++++++++++++--------------- src/invidious/views/watch.ecr | 90 +++++++++++++++++------------------ 2 files changed, 84 insertions(+), 84 deletions(-) diff --git a/src/invidious/views/embed.ecr b/src/invidious/views/embed.ecr index 8da166748..b28ce5f87 100644 --- a/src/invidious/views/embed.ecr +++ b/src/invidious/views/embed.ecr @@ -92,7 +92,7 @@ var shareOptions = { }; var player = videojs('player', options, function() { - this.hotkeys({ + this.hotkeys({ volumeStep: 0.1, seekStep: 5, enableModifiersForNumbers: false, @@ -130,45 +130,45 @@ var player = videojs('player', options, function() { } } }); + + this.share(shareOptions); + + <% if video_start > 0 || video_end > 0 %> + this.markers({ + onMarkerReached: function(marker) { + if (marker.text === 'End') { + if (player.loop()) { + player.markers.prev('Start'); + } else { + player.pause(); + } + } + }, + markers: [ + {time: <%= video_start %>, text: 'Start'}, + <% if video_end < 0 %> + {time: <%= video.info["length_seconds"].to_f - 0.5 %>, text: 'End'} + <% else %> + {time: <%= video_end %>, text: 'End'} + <% end %> + ] + }); + + this.currentTime(<%= video_start %>); + <% end %> + + <% if !listen %> + var currentSources = player.currentSources(); + for ( var i = 0; i < currentSources.length; i++ ) { + if (player.canPlayType(currentSources[i]['type'].split(';')[0]) === '') { + currentSources.splice(i); + i--; + } + } + + player.src(currentSources); + <% end %> }); - -player.share(shareOptions); - -<%- if video_start > 0 || video_end > 0 -%> -player.markers({ - onMarkerReached: function(marker) { - if (marker.text === 'End') { - if (player.loop()) { - player.markers.prev('Start'); - } else { - player.pause(); - } - } - }, - markers: [ - {time: <%= video_start %>, text: 'Start'}, - <%- if video_end < 0 -%> - {time: <%= video.info["length_seconds"].to_f - 0.5 %>, text: 'End'} - <%- else -%> - {time: <%= video_end %>, text: 'End'} - <%- end -%> - ] -}); - -player.currentTime(<%= video_start %>); -<%- end -%> - -<%- if !listen -%> -var currentSources = player.currentSources(); -for ( var i = 0; i < currentSources.length; i++ ) { - if (player.canPlayType(currentSources[i]['type'].split(';')[0]) === '') { - currentSources.splice(i); - i--; - } -} - -player.src(currentSources); -<%- end -%> diff --git a/src/invidious/views/watch.ecr b/src/invidious/views/watch.ecr index 3d1654829..3b72f82a1 100644 --- a/src/invidious/views/watch.ecr +++ b/src/invidious/views/watch.ecr @@ -40,7 +40,7 @@