From 0f6938a91d8fed65a1181005c2a2677fc419b6e0 Mon Sep 17 00:00:00 2001 From: CodeDevMLH <145071728+CodeDevMLH@users.noreply.github.com> Date: Thu, 8 Jan 2026 15:52:46 +0100 Subject: [PATCH] Add stopAllPlayback method to pause all video playback when navigating away from home screen --- .../Web/mediaBarEnhanced.js | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/Jellyfin.Plugin.MediaBarEnhanced/Web/mediaBarEnhanced.js b/Jellyfin.Plugin.MediaBarEnhanced/Web/mediaBarEnhanced.js index 5ee298d..50a0d2e 100644 --- a/Jellyfin.Plugin.MediaBarEnhanced/Web/mediaBarEnhanced.js +++ b/Jellyfin.Plugin.MediaBarEnhanced/Web/mediaBarEnhanced.js @@ -1264,6 +1264,7 @@ const VisibilityObserver = { if (STATE.slideshow.slideInterval) { STATE.slideshow.slideInterval.stop(); } + SlideshowManager.stopAllPlayback(); } }, @@ -2317,6 +2318,37 @@ const SlideshowManager = { } }, + /** + * Stops all video playback (YouTube and HTML5) + * Used when navigating away from the home screen + */ + stopAllPlayback() { + // 1. Pause all YouTube players + if (STATE.slideshow.videoPlayers) { + Object.values(STATE.slideshow.videoPlayers).forEach(player => { + try { + if (player && typeof player.pauseVideo === 'function') { + player.pauseVideo(); + } + } catch (e) { + console.warn("Error pausing YouTube player:", e); + } + }); + } + + // 2. Pause all HTML5 videos + const container = document.getElementById("slides-container"); + if (container) { + container.querySelectorAll('video').forEach(video => { + try { + video.pause(); + } catch (e) { + console.warn("Error pausing HTML5 video:", e); + } + }); + } + }, + /** * Initializes touch events for swiping */