From 9d4cbf37d355a1a83d0a8d843406ace10727da79 Mon Sep 17 00:00:00 2001 From: CodeDevMLH <145071728+CodeDevMLH@users.noreply.github.com> Date: Fri, 13 Feb 2026 03:52:07 +0100 Subject: [PATCH] Refactor slideshow state management and improve video playback logic --- .../Web/mediaBarEnhanced.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/Jellyfin.Plugin.MediaBarEnhanced/Web/mediaBarEnhanced.js b/Jellyfin.Plugin.MediaBarEnhanced/Web/mediaBarEnhanced.js index 19519fc..96869f6 100644 --- a/Jellyfin.Plugin.MediaBarEnhanced/Web/mediaBarEnhanced.js +++ b/Jellyfin.Plugin.MediaBarEnhanced/Web/mediaBarEnhanced.js @@ -2318,8 +2318,6 @@ const SlideshowManager = { } currentSlide.classList.add("active"); - - STATE.slideshow.currentSlideIndex = index; // Restore focus for TV mode navigation continuity requestAnimationFrame(() => { @@ -2354,6 +2352,8 @@ const SlideshowManager = { if (logo) logo.classList.add("animate"); } + STATE.slideshow.currentSlideIndex = index; + if (index === 0 || !previousVisibleSlide) { const dotsContainer = container.querySelector(".dots-container"); if (dotsContainer) { @@ -2708,7 +2708,7 @@ const SlideshowManager = { videoBackdrop.play().catch(() => { setTimeout(() => { - if (videoBackdrop.paused && slide.classList.contains('active')) { + if (videoBackdrop.paused) { console.warn(`Autoplay blocked for ${itemId}, attempting muted fallback`); videoBackdrop.muted = true; videoBackdrop.play().catch(err => console.error("Muted fallback failed", err)); @@ -2719,7 +2719,7 @@ const SlideshowManager = { } // YouTube player - const player = STATE.slideshow.videoPlayers?.[itemId]; + const player = STATE.slideshow.videoPlayers && STATE.slideshow.videoPlayers[itemId]; if (player && typeof player.loadVideoById === 'function' && player._videoId) { player.loadVideoById({ videoId: player._videoId, @@ -2735,8 +2735,6 @@ const SlideshowManager = { } setTimeout(() => { - if (!slide.classList.contains('active')) return; - if (player.getPlayerState && player.getPlayerState() !== YT.PlayerState.PLAYING && player.getPlayerState() !== YT.PlayerState.BUFFERING) {