Move player options into initialization

pull/77/head
Omar Roth 2018-08-03 19:51:29 -05:00
rodzic 7128881a38
commit 3398a9fe6b
2 zmienionych plików z 84 dodań i 84 usunięć

Wyświetl plik

@ -130,12 +130,11 @@ var player = videojs('player', options, function() {
}
}
});
});
player.share(shareOptions);
this.share(shareOptions);
<%- if video_start > 0 || video_end > 0 -%>
player.markers({
<% if video_start > 0 || video_end > 0 %>
this.markers({
onMarkerReached: function(marker) {
if (marker.text === 'End') {
if (player.loop()) {
@ -147,18 +146,18 @@ player.markers({
},
markers: [
{time: <%= video_start %>, text: 'Start'},
<%- if video_end < 0 -%>
<% if video_end < 0 %>
{time: <%= video.info["length_seconds"].to_f - 0.5 %>, text: 'End'}
<%- else -%>
<% else %>
{time: <%= video_end %>, text: 'End'}
<%- end -%>
<% end %>
]
});
player.currentTime(<%= video_start %>);
<%- end -%>
this.currentTime(<%= video_start %>);
<% end %>
<%- if !listen -%>
<% if !listen %>
var currentSources = player.currentSources();
for ( var i = 0; i < currentSources.length; i++ ) {
if (player.canPlayType(currentSources[i]['type'].split(';')[0]) === '') {
@ -168,7 +167,8 @@ for ( var i = 0; i < currentSources.length; i++ ) {
}
player.src(currentSources);
<%- end -%>
<% end %>
});
</script>
</body>

Wyświetl plik

@ -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>
@ -138,17 +138,11 @@ var player = videojs('player', options, function() {
}
}
});
});
player.share(shareOptions);
<% if preferences %>
player.volume(<%= preferences.volume.to_f / 100 %>);
player.playbackRate(<%= preferences.speed %>);
<% end %>
this.share(shareOptions);
<% if video_start > 0 || video_end > 0 %>
player.markers({
this.markers({
onMarkerReached: function(marker) {
if (marker.text === 'End') {
if (player.loop()) {
@ -168,7 +162,7 @@ player.markers({
]
});
player.currentTime(<%= video_start %>);
this.currentTime(<%= video_start %>);
<% end %>
<% if !listen %>
@ -183,6 +177,12 @@ for ( var i = 0; i < currentSources.length; 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];
if (body.style.display === null || body.style.display === '') {