From e3f2fd696060de3d6f70c6eab77bd5d358c82c87 Mon Sep 17 00:00:00 2001 From: tdro Date: Sat, 13 Jan 2024 20:33:21 -0500 Subject: static/js/autoplay: Set attributes Some browsers only understand attributes --- static/js/autoplay.ts | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'static') diff --git a/static/js/autoplay.ts b/static/js/autoplay.ts index 70f372a..5987576 100644 --- a/static/js/autoplay.ts +++ b/static/js/autoplay.ts @@ -12,16 +12,22 @@ ["scroll", "DOMContentLoaded"].forEach(function (event) { self.addEventListener(event, function () { - const videos = document.querySelectorAll("video"); let first = true; + let videos = document.querySelectorAll("video"); for (i = 0; i < videos.length; i++) { - videos[i].autoplay = true; - videos[i].controls = true; - videos[i].loop = true; - videos[i].muted = true; + videos[i].autoplay = true; + videos[i].controls = true; + videos[i].loop = true; + videos[i].muted = true; videos[i].playsinline = true; + videos[i].setAttribute("autoplay", true); + videos[i].setAttribute("controls", true); + videos[i].setAttribute("loop", true); + videos[i].setAttribute("muted", true); + videos[i].setAttribute("playsinline", true); + const onscreen = viewport(videos[i]); if (first && onscreen) { -- cgit v1.2.3