diff --git a/public/js/hlsPlayback.js b/public/js/hlsPlayback.js index 5cd46a6..e3435bc 100644 --- a/public/js/hlsPlayback.js +++ b/public/js/hlsPlayback.js @@ -1,25 +1,30 @@ // @license http://www.gnu.org/licenses/agpl-3.0.html AGPL-3.0 // SPDX-License-Identifier: AGPL-3.0-only -function playVideo(overlay) { - const video = overlay.parentElement.querySelector('video'); - const url = video.getAttribute("data-url"); - video.setAttribute("controls", ""); - overlay.style.display = "none"; +const video_overlay = document.getElementsByClassName("video-overlay"); - if (Hls.isSupported()) { - var hls = new Hls({autoStartLoad: false}); - hls.loadSource(url); - hls.attachMedia(video); - hls.on(Hls.Events.MANIFEST_PARSED, function () { - hls.loadLevel = hls.levels.length - 1; - hls.startLoad(); - video.play(); - }); - } else if (video.canPlayType('application/vnd.apple.mpegurl')) { - video.src = url; - video.addEventListener('canplay', function() { - video.play(); - }); - } +for (var i = 0 ; i < video_overlay.length; i++) { + video_overlay[i].addEventListener('click', function () { + + const video = this.parentElement.querySelector('video'); + const url = video.getAttribute("data-url"); + video.setAttribute("controls", ""); + this.style.display = "none"; + + if (Hls.isSupported()) { + var hls = new Hls({autoStartLoad: false}); + hls.loadSource(url); + hls.attachMedia(video); + hls.on(Hls.Events.MANIFEST_PARSED, function () { + hls.loadLevel = hls.levels.length - 1; + hls.startLoad(); + video.play(); + }); + } else if (video.canPlayType('application/vnd.apple.mpegurl')) { + video.src = url; + video.addEventListener('canplay', function() { + video.play(); + }); + } + }); } // @license-end diff --git a/src/views/tweet.nim b/src/views/tweet.nim index f47ae9a..c9bf06a 100644 --- a/src/views/tweet.nim +++ b/src/views/tweet.nim @@ -109,7 +109,7 @@ proc renderVideo*(video: Video; prefs: Prefs; path: string): VNode = source(src=source, `type`="video/mp4") of m3u8, vmap: video(poster=thumb, data-url=source, data-autoload="false", muted=prefs.muteVideos) - verbatim "
" + verbatim "
" tdiv(class="overlay-circle"): span(class="overlay-triangle") verbatim "
" if container.len > 0: