From 8292c8db57b1c962f7fc5a65ea1a78e3eeec5231 Mon Sep 17 00:00:00 2001 From: Lomanic Date: Mon, 26 Apr 2021 08:42:42 +0200 Subject: [PATCH] Fix #14 implement video autoplay with URL parameter Fixes https://todo.sr.ht/~cadence/tube/14 --- api/video.js | 3 ++- pug/video.pug | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/api/video.js b/api/video.js index ad82499..5651248 100644 --- a/api/video.js +++ b/api/video.js @@ -190,6 +190,7 @@ module.exports = [ // Continuous mode const continuous = url.searchParams.get("continuous") === "1" + const autoplay = url.searchParams.get("autoplay") === "1" const swp = url.searchParams.get("session-watched") const sessionWatched = swp ? swp.split(" ") : [] const sessionWatchedNext = sessionWatched.concat([id]).join("+") @@ -210,7 +211,7 @@ module.exports = [ return renderVideo(video, { user, settings, id, instanceOrigin }, { - mediaFragment, continuous, sessionWatched, sessionWatchedNext + mediaFragment, autoplay, continuous, sessionWatched, sessionWatchedNext }) } } diff --git a/pug/video.pug b/pug/video.pug index c1d4c5a..f1f375e 100644 --- a/pug/video.pug +++ b/pug/video.pug @@ -24,7 +24,7 @@ block content .video-container - const format = formats[0] if format - video(controls preload="auto" width=format.second__width height=format.second__height data-itag=format.itag autoplay=continuous)#video.video + video(controls preload="auto" width=format.second__width height=format.second__height data-itag=format.itag autoplay=continuous||autoplay)#video.video source(src=format.url+mediaFragment type=format.type) each t in video.captions track(label=t.label kind="subtitles" srclang=t.languageCode src=t.url)