Add player title and thumbnail

This commit is contained in:
Omar Roth 2018-03-07 16:48:26 -06:00
parent 212ba05047
commit 24fc14ac7a
4 changed files with 8 additions and 8 deletions

View File

@ -229,6 +229,8 @@ get "/watch" do |env|
video.description = fill_links(video.description, "https", "www.youtube.com")
video.description = add_alt_links(video.description)
thumbnail = player_response["videoDetails"]["thumbnail"]["thumbnails"][-1]["url"]?
templated "watch"
end

View File

@ -1,9 +1,7 @@
<audio id="player" class="video-js" data-setup="{}" style="width:100%;" controls>
<audio poster="<%= thumbnail %>" title="<%= video.title%>" id="player" class="video-js" data-setup="{}" style="width:100%;" controls>
<% adaptive_fmts.each do |fmt| %>
<% url = fmt["url"]? %>
<% type = fmt["type"]? ? fmt["type"].to_s.split(";")[0] : "" %>
<% if type.starts_with?("audio") %>
<source src="<%= url %>" type="<%= type %>">
<% if fmt["type"].starts_with?("audio") %>
<source src="<%= fmt["url"] %>" type='<%= fmt["type"] %>'>
<% end %>
<% end %>
</audio>

View File

@ -1,5 +1,5 @@
<video id="player" class="video-js" data-setup="{}" style="width:100%;" controls>
<video poster="<%= thumbnail %>" title="<%= video.title%>" id="player" class="video-js" data-setup="{}" style="width:100%;" controls>
<% fmt_stream.each do |fmt| %>
<source src="<%= fmt["url"]? %>" type="<%= fmt["type"]? ? fmt["type"].to_s.split(";")[0] : "" %>">
<source src="<%= fmt["url"]? %>" type='<%= fmt["type"]? %>'>
<% end %>
</video>

View File

@ -1,4 +1,5 @@
<% content_for "header" do %>
<meta name="thumbnail" content="<%= thumbnail %>">
<link rel="stylesheet" href="http://vjs.zencdn.net/6.6.3/video-js.css">
<script src="http://vjs.zencdn.net/6.6.3/video.js"></script>
<script src="//cdn.sc.gl/videojs-hotkeys/latest/videojs.hotkeys.min.js"></script>
@ -13,7 +14,6 @@
<script>
var options = {
poster: "<%= player_response["videoDetails"]["thumbnail"]["thumbnails"][-1]["url"]? %>",
aspectRatio: "16:9",
preload: "auto",
playbackRates: [0.5, 1, 1.5, 2]