Add 'autoplay' and 'loop' query params to watch page

pull/38/head
Omar Roth 6 years ago
parent fff0a25c17
commit 56e35def8a

@ -274,6 +274,20 @@ get "/watch" do |env|
next env.redirect "/" next env.redirect "/"
end end
autoplay = env.params.query["autoplay"]?.try &.to_i
video_loop = env.params.query["video_loop"]?.try &.to_i
if preferences
autoplay ||= preferences.autoplay.to_unsafe
video_loop ||= preferences.video_loop.to_unsafe
end
autoplay ||= 0
video_loop ||= 0
autoplay = autoplay == 1
video_loop = video_loop == 1
if env.params.query["start"]? if env.params.query["start"]?
video_start = decode_time(env.params.query["start"]) video_start = decode_time(env.params.query["start"])
end end

@ -12,10 +12,8 @@
<div class="h-box"> <div class="h-box">
<video style="width:100%" playsinline poster="<%= thumbnail %>" title="<%= HTML.escape(video.title) %>" <video style="width:100%" playsinline poster="<%= thumbnail %>" title="<%= HTML.escape(video.title) %>"
id="player" class="video-js vjs-16-9" data-setup="{}" id="player" class="video-js vjs-16-9" data-setup="{}"
<% if preferences %> <% if autoplay %>autoplay<% end %>
<% if preferences.autoplay %>autoplay<% end %> <% if video_loop %>loop<% end %>
<% if preferences.video_loop %>loop<% end %>
<% end %>
controls> controls>
<% if listen %> <% if listen %>
<% audio_streams.each_with_index do |fmt, i| %> <% audio_streams.each_with_index do |fmt, i| %>

Loading…
Cancel
Save