2018-11-15 23:52:53 +00:00
|
|
|
<<% if params[:listen]%>audio<% else %>video<% end %> style="width:100%" playsinline poster="<%= thumbnail %>" title="<%= HTML.escape(video.title) %>"
|
2018-08-11 15:52:13 +00:00
|
|
|
id="player" class="video-js"
|
2018-11-26 01:01:04 +00:00
|
|
|
onmouseenter='this["data-title"]=this["title"];this["title"]=""'
|
|
|
|
onmouseleave='this["title"]=this["data-title"];this["data-title"]=""'
|
|
|
|
oncontextmenu='this["title"]=this["data-title"]'
|
2018-08-26 01:05:51 +00:00
|
|
|
<% if params[:autoplay] %>autoplay<% end %>
|
|
|
|
<% if params[:video_loop] %>loop<% end %>
|
|
|
|
<% if params[:controls] %>controls<% end %>>
|
2018-08-11 15:52:13 +00:00
|
|
|
<% if hlsvp %>
|
2018-09-20 14:45:49 +00:00
|
|
|
<source src="<%= hlsvp %>" type="application/x-mpegURL" label="livestream">
|
2018-08-11 15:52:13 +00:00
|
|
|
<% else %>
|
2018-08-26 01:05:51 +00:00
|
|
|
<% if params[:listen] %>
|
2018-08-11 15:52:13 +00:00
|
|
|
<% audio_streams.each_with_index do |fmt, i| %>
|
2018-09-05 15:49:40 +00:00
|
|
|
<source src="<%= fmt["url"] %>" type='<%= fmt["type"] %>' label="<%= fmt["bitrate"] %>k" selected="<%= i == 0 ? true : false %>">
|
2018-08-11 15:52:13 +00:00
|
|
|
<% end %>
|
|
|
|
<% else %>
|
2018-09-25 00:28:36 +00:00
|
|
|
<% if params[:quality] == "dash" %>
|
|
|
|
<source src="/api/manifest/dash/id/<%= video.id %>?local=true" type='application/dash+xml' label="dash">
|
|
|
|
<% end %>
|
2018-08-11 15:52:13 +00:00
|
|
|
<% fmt_stream.each_with_index do |fmt, i| %>
|
2018-08-26 01:05:51 +00:00
|
|
|
<% if params[:quality] %>
|
2018-09-05 15:49:40 +00:00
|
|
|
<source src="<%= fmt["url"] %>" type='<%= fmt["type"] %>' label="<%= fmt["label"] %>" selected="<%= params[:quality] == fmt["label"].split(" - ")[0] %>">
|
2018-08-11 15:52:13 +00:00
|
|
|
<% else %>
|
2018-09-05 15:49:40 +00:00
|
|
|
<source src="<%= fmt["url"] %>" type='<%= fmt["type"] %>' label="<%= fmt["label"] %>" selected="<%= i == 0 ? true : false %>">
|
2018-08-11 15:52:13 +00:00
|
|
|
<% end %>
|
|
|
|
<% end %>
|
|
|
|
<% end %>
|
|
|
|
|
|
|
|
<% preferred_captions.each_with_index do |caption, i| %>
|
|
|
|
<track kind="captions" src="/api/v1/captions/<%= video.id %>?label=<%= caption.name.simpleText %>"
|
|
|
|
label="<%= caption.name.simpleText %>" <% if i == 0 %>default<% end %>>
|
|
|
|
<% end %>
|
|
|
|
|
|
|
|
<% captions.each do |caption| %>
|
|
|
|
<track kind="captions" src="/api/v1/captions/<%= video.id %>?label=<%= caption.name.simpleText %>"
|
|
|
|
label="<%= caption.name.simpleText %>">
|
|
|
|
<% end %>
|
|
|
|
<% end %>
|
2018-11-15 23:52:53 +00:00
|
|
|
</<% if params[:listen]%>audio<% else %>video<% end %>>
|
2018-08-11 15:52:13 +00:00
|
|
|
|
|
|
|
<script>
|
|
|
|
var options = {
|
|
|
|
<% if aspect_ratio %>
|
|
|
|
aspectRatio: "<%= aspect_ratio %>",
|
|
|
|
<% end %>
|
|
|
|
preload: "auto",
|
|
|
|
playbackRates: [0.5, 1, 1.5, 2],
|
|
|
|
controlBar: {
|
|
|
|
children: [
|
|
|
|
"playToggle",
|
|
|
|
"volumePanel",
|
|
|
|
"currentTimeDisplay",
|
|
|
|
"timeDivider",
|
|
|
|
"durationDisplay",
|
|
|
|
"progressControl",
|
|
|
|
"remainingTimeDisplay",
|
|
|
|
"captionsButton",
|
|
|
|
"qualitySelector",
|
|
|
|
"playbackRateMenuButton",
|
|
|
|
"fullscreenToggle"
|
|
|
|
]
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
var shareOptions = {
|
|
|
|
socials: ["fb", "tw", "reddit", "mail"],
|
|
|
|
|
|
|
|
url: "<%= host_url %>/<%= video.id %>?<%= host_params %>",
|
|
|
|
title: "<%= video.title.dump_unquoted %>",
|
|
|
|
description: "<%= description %>",
|
|
|
|
image: "<%= thumbnail %>",
|
2018-09-13 23:12:19 +00:00
|
|
|
embedCode: "<iframe id='ivplayer' type='text/html' width='640' height='360' \
|
|
|
|
src='<%= host_url %>/embed/<%= video.id %>?<%= host_params %>' frameborder='0'></iframe>"
|
2018-08-11 15:52:13 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
var player = videojs("player", options, function() {
|
|
|
|
this.hotkeys({
|
|
|
|
volumeStep: 0.1,
|
|
|
|
seekStep: 5,
|
|
|
|
enableModifiersForNumbers: false,
|
|
|
|
customKeys: {
|
|
|
|
play: {
|
|
|
|
key: function(e) {
|
|
|
|
// Toggle play with K Key
|
|
|
|
return e.which === 75;
|
|
|
|
},
|
|
|
|
handler: function(player, options, e) {
|
|
|
|
if (player.paused()) {
|
|
|
|
player.play();
|
|
|
|
} else {
|
|
|
|
player.pause();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
backward: {
|
|
|
|
key: function(e) {
|
|
|
|
// Go backward 5 seconds
|
|
|
|
return e.which === 74;
|
|
|
|
},
|
|
|
|
handler: function(player, options, e) {
|
|
|
|
player.currentTime(player.currentTime() - 5);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
forward: {
|
|
|
|
key: function(e) {
|
|
|
|
// Go forward 5 seconds
|
|
|
|
return e.which === 76;
|
|
|
|
},
|
|
|
|
handler: function(player, options, e) {
|
|
|
|
player.currentTime(player.currentTime() + 5);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
player.share(shareOptions);
|
|
|
|
|
2018-08-26 01:05:51 +00:00
|
|
|
<% if params[:video_start] > 0 || params[:video_end] > 0 %>
|
2018-08-11 15:52:13 +00:00
|
|
|
player.markers({
|
|
|
|
onMarkerReached: function(marker) {
|
|
|
|
if (marker.text === "End") {
|
|
|
|
if (player.loop()) {
|
|
|
|
player.markers.prev("Start");
|
|
|
|
} else {
|
|
|
|
player.pause();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
markers: [
|
2018-08-26 01:05:51 +00:00
|
|
|
{ time: <%= params[:video_start] %>, text: "Start" },
|
|
|
|
<% if params[:video_end] < 0 %>
|
2018-08-11 15:52:13 +00:00
|
|
|
{ time: <%= video.info["length_seconds"].to_f - 0.5 %>, text: "End" }
|
|
|
|
<% else %>
|
2018-08-26 01:05:51 +00:00
|
|
|
{ time: <%= params[:video_end] %>, text: "End" }
|
2018-08-11 15:52:13 +00:00
|
|
|
<% end %>
|
|
|
|
]
|
|
|
|
});
|
|
|
|
|
2018-08-26 01:05:51 +00:00
|
|
|
player.currentTime(<%= params[:video_start] %>);
|
2018-08-11 15:52:13 +00:00
|
|
|
<% end %>
|
|
|
|
|
2018-08-26 01:05:51 +00:00
|
|
|
player.volume(<%= params[:volume].to_f / 100 %>);
|
|
|
|
player.playbackRate(<%= params[:speed] %>);
|
2018-08-11 15:52:13 +00:00
|
|
|
</script>
|