Enhance video playback logic by introducing a play signal check for active slides
This commit is contained in:
@@ -1879,11 +1879,11 @@ const SlideCreator = {
|
|||||||
event.target.setPlaybackQuality(quality);
|
event.target.setPlaybackQuality(quality);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only play if this is the active slide
|
// Only play if this is the active slide and the play signal has been issued (delay finished)
|
||||||
const slide = document.querySelector(`.slide[data-item-id="${itemId}"]`);
|
const slide = document.querySelector(`.slide[data-item-id="${itemId}"]`);
|
||||||
const isVideoPlayerOpen = document.querySelector('.videoPlayerContainer') || document.querySelector('.youtubePlayerContainer');
|
const isVideoPlayerOpen = document.querySelector('.videoPlayerContainer') || document.querySelector('.youtubePlayerContainer');
|
||||||
|
|
||||||
if (slide && slide.classList.contains('active') && !document.hidden && (!isVideoPlayerOpen || isVideoPlayerOpen.classList.contains('hide'))) {
|
if (slide && slide.classList.contains('active') && slide.dataset.playVideoSignal === "true" && !document.hidden && (!isVideoPlayerOpen || isVideoPlayerOpen.classList.contains('hide'))) {
|
||||||
event.target.playVideo();
|
event.target.playVideo();
|
||||||
|
|
||||||
// Check if it actually started playing after a short delay (handling autoplay blocks)
|
// Check if it actually started playing after a short delay (handling autoplay blocks)
|
||||||
@@ -2481,6 +2481,7 @@ const SlideshowManager = {
|
|||||||
|
|
||||||
void currentSlide.offsetWidth;
|
void currentSlide.offsetWidth;
|
||||||
currentSlide.classList.add("active");
|
currentSlide.classList.add("active");
|
||||||
|
currentSlide.dataset.playVideoSignal = "false";
|
||||||
|
|
||||||
// Manage Video Playback: Stop others, Play current
|
// Manage Video Playback: Stop others, Play current
|
||||||
// 1. Stop all other YouTube players and local video elements, release connections
|
// 1. Stop all other YouTube players and local video elements, release connections
|
||||||
@@ -2581,6 +2582,8 @@ const SlideshowManager = {
|
|||||||
// play logic
|
// play logic
|
||||||
const playVideoLogic = () => {
|
const playVideoLogic = () => {
|
||||||
if (!currentSlide.classList.contains('active')) return;
|
if (!currentSlide.classList.contains('active')) return;
|
||||||
|
|
||||||
|
currentSlide.dataset.playVideoSignal = "true";
|
||||||
|
|
||||||
if (videoBackdrop.tagName === 'VIDEO') {
|
if (videoBackdrop.tagName === 'VIDEO') {
|
||||||
videoBackdrop.play().catch(e => {
|
videoBackdrop.play().catch(e => {
|
||||||
|
|||||||
Reference in New Issue
Block a user