From c7cd7be3ee086707225f07fb5aa1c7481f8ae3bb Mon Sep 17 00:00:00 2001 From: CodeDevMLH <145071728+CodeDevMLH@users.noreply.github.com> Date: Fri, 6 Mar 2026 02:16:09 +0100 Subject: [PATCH] Add low-power device detection and adjust video playback settings --- .../Web/mediaBarEnhanced.js | 24 +++++++++++++++---- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/Jellyfin.Plugin.MediaBarEnhanced/Web/mediaBarEnhanced.js b/Jellyfin.Plugin.MediaBarEnhanced/Web/mediaBarEnhanced.js index b5aa2d6..3530e5d 100644 --- a/Jellyfin.Plugin.MediaBarEnhanced/Web/mediaBarEnhanced.js +++ b/Jellyfin.Plugin.MediaBarEnhanced/Web/mediaBarEnhanced.js @@ -163,6 +163,14 @@ const isUserLoggedIn = () => { } }; +/** + * Detects if the current device is a low-power device (Smart TVs, etc.) + * @returns {boolean} True if running on a low-power device + */ +const isLowPowerDevice = () => { + return /webOS|LG Browser|SMART-TV|SmartTV|Tizen|Viera|NetCast|Roku|VIDAA/i.test(navigator.userAgent); +}; + /** * Initializes Jellyfin data from ApiClient * @param {Function} callback - Function to call once data is initialized @@ -1696,7 +1704,7 @@ const SlideCreator = { console.log(`Using local trailer fallback for ${itemId}: ${trailerUrl}`); } - const isMobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent); + const isMobile = /Android|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent); // Client Setting Overrides const enableVideo = MediaBarEnhancedSettingsManager.getSetting('videoBackdrops', CONFIG.enableVideoBackdrop); @@ -1726,7 +1734,11 @@ const SlideCreator = { console.warn("Invalid trailer URL:", trailerUrl); } - if (isYoutube && videoId) { + const isLowPower = isLowPowerDevice(); + const isActiveSlide = index === STATE.slideshow.currentSlideIndex; + const shouldCreateVideo = !isLowPower || isActiveSlide; + + if (isYoutube && videoId && shouldCreateVideo) { isVideo = true; // Create container for YouTube API const videoClass = CONFIG.fullWidthVideo ? "video-backdrop-full" : "video-backdrop-default"; @@ -1883,7 +1895,7 @@ const SlideCreator = { }); // 2. Check for local video trailers in MediaSources if yt is not available - } else if (!isYoutube) { + } else if (!isYoutube && shouldCreateVideo) { isVideo = true; const videoSrc = (typeof trailerUrl === 'object' ? trailerUrl.url : trailerUrl); @@ -2575,7 +2587,7 @@ const SlideshowManager = { STATE.slideshow.isTransitioning = false; if (previousVisibleSlide) { - const enableAnimations = MediaBarEnhancedSettingsManager.getSetting('slideAnimations', CONFIG.slideAnimationEnabled); + const enableAnimations = MediaBarEnhancedSettingsManager.getSetting('slideAnimations', CONFIG.slideAnimationEnabled) && !isLowPowerDevice(); if (enableAnimations) { const prevBackdrop = previousVisibleSlide.querySelector(".backdrop"); const prevLogo = previousVisibleSlide.querySelector(".logo"); @@ -2616,7 +2628,9 @@ const SlideshowManager = { */ async preloadAdjacentSlides(currentIndex) { const totalItems = STATE.slideshow.totalItems; - const preloadCount = Math.min(Math.max(CONFIG.preloadCount || 1, 1), 5); + let preloadCount = Math.min(Math.max(CONFIG.preloadCount || 1, 1), 5); + if (isLowPowerDevice()) preloadCount = 1; // Strict limit for TVs + const preloadedIds = new Set(); // Preload next slides