Skip to content

Commit

Permalink
Move player options into initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
omarroth committed Aug 4, 2018
1 parent 7128881 commit 3398a9f
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 78 deletions.
72 changes: 36 additions & 36 deletions src/invidious/views/embed.ecr
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ var shareOptions = {
};
var player = videojs('player', options, function() {
this.hotkeys({
this.hotkeys({
volumeStep: 0.1,
seekStep: 5,
enableModifiersForNumbers: false,
Expand Down Expand Up @@ -130,45 +130,45 @@ var player = videojs('player', options, function() {
}
}
});
});
player.share(shareOptions);
this.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 -%>
]
});
<% 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 %>
]
});
player.currentTime(<%= video_start %>);
<%- 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 -%>
<% 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 %>
});
</script>
</body>

Expand Down
84 changes: 42 additions & 42 deletions src/invidious/views/watch.ecr
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@

<div class="h-box">
<video style="width:100%" playsinline poster="<%= thumbnail %>" title="<%= HTML.escape(video.title) %>"
id="player" class="video-js" data-setup="{}"
id="player" class="video-js"
<% if autoplay %>autoplay<% end %>
<% if video_loop %>loop<% end %>
controls>
Expand Down Expand Up @@ -100,7 +100,7 @@ var shareOptions = {
};
var player = videojs('player', options, function() {
this.hotkeys({
this.hotkeys({
volumeStep: 0.1,
seekStep: 5,
enableModifiersForNumbers: false,
Expand Down Expand Up @@ -138,50 +138,50 @@ var player = videojs('player', options, function() {
}
}
});
});
player.share(shareOptions);
<% if preferences %>
player.volume(<%= preferences.volume.to_f / 100 %>);
player.playbackRate(<%= preferences.speed %>);
<% end %>
<% 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 %>
]
});
this.share(shareOptions);
player.currentTime(<%= video_start %>);
<% end %>
<% 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 %>
]
});
<% 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--;
}
}
this.currentTime(<%= video_start %>);
<% end %>
player.src(currentSources);
<% 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 %>
<% if preferences %>
this.volume(<%= preferences.volume.to_f / 100 %>);
this.playbackRate(<%= preferences.speed %>);
<% end %>
});
function toggle(target) {
body = target.parentNode.parentNode.children[1];
Expand Down

0 comments on commit 3398a9f

Please sign in to comment.