mirror of
https://github.com/redlib-org/redlib.git
synced 2025-04-22 14:59:15 +00:00
Merge e377f47caf
into cbc3e49923
This commit is contained in:
commit
5bd0722b47
1 changed files with 12 additions and 1 deletions
|
@ -109,10 +109,21 @@
|
||||||
videoElement.parentNode.appendChild(qualitySelector);
|
videoElement.parentNode.appendChild(qualitySelector);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// IntersectionObserver to autoplay/pause video based on visibility
|
||||||
|
var autoplayObserver = new IntersectionObserver(function(entries) {
|
||||||
|
entries.forEach(function(entry) {
|
||||||
|
if (entry.isIntersecting) {
|
||||||
|
newVideo.play();
|
||||||
|
} else {
|
||||||
|
newVideo.pause();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}, { threshold: 0.5 }); // Adjust the threshold as needed
|
||||||
|
|
||||||
newVideo.addEventListener('play', initializeHls);
|
newVideo.addEventListener('play', initializeHls);
|
||||||
|
|
||||||
if (autoplay) {
|
if (autoplay) {
|
||||||
newVideo.play();
|
autoplayObserver.observe(newVideo);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Add table
Reference in a new issue