Add &start and &end to watch page

This commit is contained in:
Omar Roth 2018-04-05 20:46:32 -05:00
parent ff91ec820c
commit 841308929d
2 changed files with 12 additions and 0 deletions

View File

@ -207,6 +207,12 @@ get "/watch" do |env|
next env.redirect "/" next env.redirect "/"
end end
video_start = env.params.query["start"]?.try &.to_i
video_start ||= 0
video_end = env.params.query["end"]?.try &.to_i
video_end ||= -1
listen = false listen = false
if env.params.query["listen"]? && env.params.query["listen"] == "true" if env.params.query["listen"]? && env.params.query["listen"] == "true"
listen = true listen = true

View File

@ -5,6 +5,7 @@
<script src="https://vjs.zencdn.net/6.6.3/video.js"></script> <script src="https://vjs.zencdn.net/6.6.3/video.js"></script>
<script src="https://cdn.sc.gl/videojs-hotkeys/latest/videojs.hotkeys.min.js"></script> <script src="https://cdn.sc.gl/videojs-hotkeys/latest/videojs.hotkeys.min.js"></script>
<script src="https://unpkg.com/silvermine-videojs-quality-selector/dist/js/silvermine-videojs-quality-selector.min.js"></script> <script src="https://unpkg.com/silvermine-videojs-quality-selector/dist/js/silvermine-videojs-quality-selector.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/videojs-offset/dist/videojs-offset.min.js"></script>
<title><%= video.title %> - Invidious</title> <title><%= video.title %> - Invidious</title>
<% end %> <% end %>
@ -74,6 +75,11 @@ var player = videojs('player', options, function() {
} }
}); });
}); });
player.offset({
start: <%= video_start %>,
end: <%= video_end %>,
restart_beginning: true
});
function toggle(target) { function toggle(target) {
body = target.parentNode.parentNode.children[1]; body = target.parentNode.parentNode.children[1];