Skip to content

Invidious is an alternative front-end to YouTube

Fix iOS screen timeout on video playback loop mode

Ming Kin Choi2a092577c69d
diff --git a/assets/js/player.js b/assets/js/player.js
index bb53ac24..0c37033d 100644
--- a/assets/js/player.js
+++ b/assets/js/player.js
@@ -701,6 +701,21 @@ if (navigator.vendor === 'Apple Computer, Inc.' && video_data.params.listen) {
});
}
+// Safari screen timeout on looped video playback fix
+if (navigator.vendor === 'Apple Computer, Inc.' && !video_data.params.listen && video_data.params.video_loop) {
+ player.loop(false);
+ player.on('loadedmetadata', function () {
+ player.on('timeupdate', function () {
+ if (player.remainingTime() < 2) {
+ player.loop(true);
+ setTimeout(() => {
+ player.loop(false);
+ }, 2000 / player.playbackRate());
+ }
+ });
+ });
+}
+
// Watch on Invidious link
if (location.pathname.startsWith('/embed/')) {
const Button = videojs.getComponent('Button');