|
|
|
@@ -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
|
|
|
|
* Initializes Jellyfin data from ApiClient
|
|
|
|
* @param {Function} callback - Function to call once data is initialized
|
|
|
|
* @param {Function} callback - Function to call once data is initialized
|
|
|
|
@@ -734,17 +742,20 @@ const SlideUtils = {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (isYoutube && videoId) {
|
|
|
|
if (isYoutube && videoId) {
|
|
|
|
const playerDiv = this.createElement('div', { id: 'modal-yt-player' });
|
|
|
|
const ytIframe = this.createElement('iframe', {
|
|
|
|
contentContainer.appendChild(playerDiv);
|
|
|
|
id: 'modal-yt-player',
|
|
|
|
|
|
|
|
src: `https://www.youtube-nocookie.com/embed/${videoId}?enablejsapi=1&origin=${encodeURIComponent(window.location.origin)}`,
|
|
|
|
|
|
|
|
allow: 'autoplay; encrypted-media',
|
|
|
|
|
|
|
|
style: 'width: 100%; height: 100%; border: none;',
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
ytIframe.setAttribute('referrerpolicy', 'strict-origin-when-cross-origin');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
contentContainer.appendChild(ytIframe);
|
|
|
|
overlay.append(closeButton, contentContainer);
|
|
|
|
overlay.append(closeButton, contentContainer);
|
|
|
|
document.body.appendChild(overlay);
|
|
|
|
document.body.appendChild(overlay);
|
|
|
|
|
|
|
|
|
|
|
|
this.loadYouTubeIframeAPI().then(() => {
|
|
|
|
this.loadYouTubeIframeAPI().then(() => {
|
|
|
|
new YT.Player('modal-yt-player', {
|
|
|
|
new YT.Player(ytIframe, {
|
|
|
|
height: '100%',
|
|
|
|
|
|
|
|
width: '100%',
|
|
|
|
|
|
|
|
videoId: videoId,
|
|
|
|
|
|
|
|
host: 'https://www.youtube-nocookie.com',
|
|
|
|
|
|
|
|
playerVars: {
|
|
|
|
playerVars: {
|
|
|
|
autoplay: 1,
|
|
|
|
autoplay: 1,
|
|
|
|
controls: 1,
|
|
|
|
controls: 1,
|
|
|
|
@@ -753,14 +764,6 @@ const SlideUtils = {
|
|
|
|
playsinline: 1,
|
|
|
|
playsinline: 1,
|
|
|
|
origin: window.location.origin,
|
|
|
|
origin: window.location.origin,
|
|
|
|
enablejsapi: 1
|
|
|
|
enablejsapi: 1
|
|
|
|
},
|
|
|
|
|
|
|
|
events: {
|
|
|
|
|
|
|
|
'onReady': (event) => {
|
|
|
|
|
|
|
|
const iframe = event.target.getIframe();
|
|
|
|
|
|
|
|
if (iframe) {
|
|
|
|
|
|
|
|
iframe.setAttribute('referrerpolicy', 'strict-origin-when-cross-origin');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
@@ -1403,7 +1406,7 @@ const ApiUtils = {
|
|
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
return {
|
|
|
|
id: trailer.Id,
|
|
|
|
id: trailer.Id,
|
|
|
|
url: `${STATE.jellyfinData.serverAddress}/Videos/${trailer.Id}/stream.mp4?mediaSourceId=${mediaSourceId}&api_key=${STATE.jellyfinData.accessToken}`
|
|
|
|
url: `${STATE.jellyfinData.serverAddress}/Videos/${trailer.Id}/stream.mp4?mediaSourceId=${mediaSourceId}&api_key=${STATE.jellyfinData.accessToken}&static=true`
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
return null;
|
|
|
|
@@ -1442,7 +1445,7 @@ const ApiUtils = {
|
|
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
return {
|
|
|
|
id: video.Id,
|
|
|
|
id: video.Id,
|
|
|
|
url: `${STATE.jellyfinData.serverAddress}/Videos/${video.Id}/stream.mp4?api_key=${STATE.jellyfinData.accessToken}`
|
|
|
|
url: `${STATE.jellyfinData.serverAddress}/Videos/${video.Id}/stream.mp4?api_key=${STATE.jellyfinData.accessToken}&static=true`
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@@ -1668,7 +1671,7 @@ const SlideCreator = {
|
|
|
|
|
|
|
|
|
|
|
|
trailerUrl = {
|
|
|
|
trailerUrl = {
|
|
|
|
id: videoId,
|
|
|
|
id: videoId,
|
|
|
|
url: `${STATE.jellyfinData.serverAddress}/Videos/${videoId}/stream.mp4?api_key=${STATE.jellyfinData.accessToken}`
|
|
|
|
url: `${STATE.jellyfinData.serverAddress}/Videos/${videoId}/stream.mp4?api_key=${STATE.jellyfinData.accessToken}&static=true`
|
|
|
|
};
|
|
|
|
};
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
// Assume it's a standard URL (YouTube, etc.)
|
|
|
|
// Assume it's a standard URL (YouTube, etc.)
|
|
|
|
@@ -1696,7 +1699,7 @@ const SlideCreator = {
|
|
|
|
console.log(`Using local trailer fallback for ${itemId}: ${trailerUrl}`);
|
|
|
|
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
|
|
|
|
// Client Setting Overrides
|
|
|
|
const enableVideo = MediaBarEnhancedSettingsManager.getSetting('videoBackdrops', CONFIG.enableVideoBackdrop);
|
|
|
|
const enableVideo = MediaBarEnhancedSettingsManager.getSetting('videoBackdrops', CONFIG.enableVideoBackdrop);
|
|
|
|
@@ -1726,7 +1729,12 @@ const SlideCreator = {
|
|
|
|
console.warn("Invalid trailer URL:", trailerUrl);
|
|
|
|
console.warn("Invalid trailer URL:", trailerUrl);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (isYoutube && videoId) {
|
|
|
|
const isLowPower = isLowPowerDevice();
|
|
|
|
|
|
|
|
const itemIndex = STATE.slideshow.itemIds ? STATE.slideshow.itemIds.indexOf(itemId) : -1;
|
|
|
|
|
|
|
|
const isActiveSlide = itemIndex !== -1 && itemIndex === STATE.slideshow.currentSlideIndex;
|
|
|
|
|
|
|
|
const shouldCreateVideo = !isLowPower || isActiveSlide;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (isYoutube && videoId && shouldCreateVideo) {
|
|
|
|
isVideo = true;
|
|
|
|
isVideo = true;
|
|
|
|
// Create container for YouTube API
|
|
|
|
// Create container for YouTube API
|
|
|
|
const videoClass = CONFIG.fullWidthVideo ? "video-backdrop-full" : "video-backdrop-default";
|
|
|
|
const videoClass = CONFIG.fullWidthVideo ? "video-backdrop-full" : "video-backdrop-default";
|
|
|
|
@@ -1737,20 +1745,24 @@ const SlideCreator = {
|
|
|
|
style: "opacity: 0; transition: opacity 1.2s ease-in-out;" // Start interrupted/transparent
|
|
|
|
style: "opacity: 0; transition: opacity 1.2s ease-in-out;" // Start interrupted/transparent
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
const ytPlayerDiv = SlideUtils.createElement("div", {
|
|
|
|
// Create an iframe upfront
|
|
|
|
|
|
|
|
const ytPlayerIframe = SlideUtils.createElement("iframe", {
|
|
|
|
id: `youtube-player-${itemId}`,
|
|
|
|
id: `youtube-player-${itemId}`,
|
|
|
|
style: "width: 100%; height: 100%;"
|
|
|
|
src: `https://www.youtube-nocookie.com/embed/${videoId}?enablejsapi=1&origin=${encodeURIComponent(window.location.origin)}`,
|
|
|
|
|
|
|
|
style: "width: 100%; height: 100%; border: none;",
|
|
|
|
|
|
|
|
allow: "autoplay; encrypted-media",
|
|
|
|
|
|
|
|
referrerpolicy: "strict-origin-when-cross-origin"
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
videoBackdrop.appendChild(ytPlayerDiv);
|
|
|
|
videoBackdrop.appendChild(ytPlayerIframe);
|
|
|
|
|
|
|
|
|
|
|
|
// Initialize YouTube Player
|
|
|
|
// Initialize YouTube Player
|
|
|
|
SlideUtils.loadYouTubeIframeAPI().then(() => {
|
|
|
|
SlideUtils.loadYouTubeIframeAPI().then(() => {
|
|
|
|
// Fetch SponsorBlock data
|
|
|
|
// Fetch SponsorBlock data
|
|
|
|
ApiUtils.fetchSponsorBlockData(videoId).then(segments => {
|
|
|
|
ApiUtils.fetchSponsorBlockData(videoId).then(segments => {
|
|
|
|
const playerVars = {
|
|
|
|
const playerVars = {
|
|
|
|
autoplay: 1,
|
|
|
|
autoplay: 0,
|
|
|
|
mute: 1, // need to be muted for Safari, because apple makes life difficult...
|
|
|
|
mute: STATE.slideshow.isMuted ? 1 : 0,
|
|
|
|
controls: 0,
|
|
|
|
controls: 0,
|
|
|
|
disablekb: 1,
|
|
|
|
disablekb: 1,
|
|
|
|
fs: 0,
|
|
|
|
fs: 0,
|
|
|
|
@@ -1787,19 +1799,10 @@ const SlideCreator = {
|
|
|
|
console.info(`SponsorBlock outro detected for video ${videoId}: ending at ${playerVars.end}s`);
|
|
|
|
console.info(`SponsorBlock outro detected for video ${videoId}: ending at ${playerVars.end}s`);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
STATE.slideshow.videoPlayers[itemId] = new YT.Player(`youtube-player-${itemId}`, {
|
|
|
|
STATE.slideshow.videoPlayers[itemId] = new YT.Player(ytPlayerIframe, {
|
|
|
|
height: '100%',
|
|
|
|
|
|
|
|
width: '100%',
|
|
|
|
|
|
|
|
videoId: videoId,
|
|
|
|
|
|
|
|
host: 'https://www.youtube-nocookie.com',
|
|
|
|
|
|
|
|
playerVars: playerVars,
|
|
|
|
playerVars: playerVars,
|
|
|
|
events: {
|
|
|
|
events: {
|
|
|
|
'onReady': (event) => {
|
|
|
|
'onReady': (event) => {
|
|
|
|
const iframe = event.target.getIframe();
|
|
|
|
|
|
|
|
if (iframe) {
|
|
|
|
|
|
|
|
iframe.setAttribute('referrerpolicy', 'strict-origin-when-cross-origin');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Store start/end time and videoId for later use
|
|
|
|
// Store start/end time and videoId for later use
|
|
|
|
event.target._startTime = playerVars.start || 0;
|
|
|
|
event.target._startTime = playerVars.start || 0;
|
|
|
|
event.target._endTime = playerVars.end || undefined;
|
|
|
|
event.target._endTime = playerVars.end || undefined;
|
|
|
|
@@ -1808,8 +1811,9 @@ const SlideCreator = {
|
|
|
|
// Store reference to wrapper for fading
|
|
|
|
// Store reference to wrapper for fading
|
|
|
|
event.target._wrapperDiv = videoBackdrop;
|
|
|
|
event.target._wrapperDiv = videoBackdrop;
|
|
|
|
|
|
|
|
|
|
|
|
// Unmute now if user wants sound.
|
|
|
|
if (STATE.slideshow.isMuted) {
|
|
|
|
if (!STATE.slideshow.isMuted) {
|
|
|
|
event.target.mute();
|
|
|
|
|
|
|
|
} else {
|
|
|
|
event.target.unMute();
|
|
|
|
event.target.unMute();
|
|
|
|
event.target.setVolume(40);
|
|
|
|
event.target.setVolume(40);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@@ -1818,34 +1822,28 @@ const SlideCreator = {
|
|
|
|
event.target.setPlaybackQuality(quality);
|
|
|
|
event.target.setPlaybackQuality(quality);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Stop playback if slide was navigated away from
|
|
|
|
// Only play if this is the active slide
|
|
|
|
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') && !document.hidden && (!isVideoPlayerOpen || isVideoPlayerOpen.classList.contains('hide'))) {
|
|
|
|
event.target.stopVideo();
|
|
|
|
event.target.playVideo();
|
|
|
|
} else {
|
|
|
|
|
|
|
|
// Pause slideshow timer when video starts if configured
|
|
|
|
|
|
|
|
if (CONFIG.waitForTrailerToEnd && STATE.slideshow.slideInterval) {
|
|
|
|
|
|
|
|
STATE.slideshow.slideInterval.stop();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Safety check after 1s: handle navigation-away during the window,
|
|
|
|
// Check if it actually started playing after a short delay (handling autoplay blocks)
|
|
|
|
// and fallback to muted play if autoplay failed for any reason.
|
|
|
|
|
|
|
|
const timeoutId = setTimeout(() => {
|
|
|
|
const timeoutId = setTimeout(() => {
|
|
|
|
|
|
|
|
// Re-check conditions before processing fallback
|
|
|
|
const isVideoPlayerOpenNow = document.querySelector('.videoPlayerContainer') || document.querySelector('.youtubePlayerContainer');
|
|
|
|
const isVideoPlayerOpenNow = document.querySelector('.videoPlayerContainer') || document.querySelector('.youtubePlayerContainer');
|
|
|
|
if (document.hidden || (isVideoPlayerOpenNow && !isVideoPlayerOpenNow.classList.contains('hide')) || !slide.classList.contains('active')) {
|
|
|
|
if (document.hidden || (isVideoPlayerOpenNow && !isVideoPlayerOpenNow.classList.contains('hide')) || !slide.classList.contains('active')) {
|
|
|
|
console.log(`Navigation detected during autoplay check for ${itemId}, stopping video.`);
|
|
|
|
console.log(`Navigation detected during autoplay check for ${itemId}, stopping video.`);
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
event.target.stopVideo();
|
|
|
|
event.target.stopVideo();
|
|
|
|
} catch (e) { console.warn("Error stopping video:", e); }
|
|
|
|
} catch (e) { console.warn("Error stopping video in timeout:", e); }
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// If somehow not playing/buffering yet, force muted fallback
|
|
|
|
if (event.target.getPlayerState() !== YT.PlayerState.PLAYING &&
|
|
|
|
const state = event.target.getPlayerState();
|
|
|
|
event.target.getPlayerState() !== YT.PlayerState.BUFFERING) {
|
|
|
|
if (state !== YT.PlayerState.PLAYING && state !== YT.PlayerState.BUFFERING) {
|
|
|
|
console.warn(`Autoplay blocked for ${itemId}, attempting muted fallback`);
|
|
|
|
console.warn(`Autoplay stalled for ${itemId}, attempting muted fallback`);
|
|
|
|
|
|
|
|
event.target.mute();
|
|
|
|
event.target.mute();
|
|
|
|
event.target.playVideo();
|
|
|
|
event.target.playVideo();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@@ -1853,6 +1851,11 @@ const SlideCreator = {
|
|
|
|
|
|
|
|
|
|
|
|
if (!STATE.slideshow.autoplayTimeouts) STATE.slideshow.autoplayTimeouts = [];
|
|
|
|
if (!STATE.slideshow.autoplayTimeouts) STATE.slideshow.autoplayTimeouts = [];
|
|
|
|
STATE.slideshow.autoplayTimeouts.push(timeoutId);
|
|
|
|
STATE.slideshow.autoplayTimeouts.push(timeoutId);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Pause slideshow timer when video starts if configured
|
|
|
|
|
|
|
|
if (CONFIG.waitForTrailerToEnd && STATE.slideshow.slideInterval) {
|
|
|
|
|
|
|
|
STATE.slideshow.slideInterval.stop();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'onStateChange': (event) => {
|
|
|
|
'onStateChange': (event) => {
|
|
|
|
@@ -1883,7 +1886,7 @@ const SlideCreator = {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
// 2. Check for local video trailers in MediaSources if yt is not available
|
|
|
|
// 2. Check for local video trailers in MediaSources if yt is not available
|
|
|
|
} else if (!isYoutube) {
|
|
|
|
} else if (!isYoutube && shouldCreateVideo) {
|
|
|
|
isVideo = true;
|
|
|
|
isVideo = true;
|
|
|
|
|
|
|
|
|
|
|
|
const videoSrc = (typeof trailerUrl === 'object' ? trailerUrl.url : trailerUrl);
|
|
|
|
const videoSrc = (typeof trailerUrl === 'object' ? trailerUrl.url : trailerUrl);
|
|
|
|
@@ -1896,7 +1899,6 @@ const SlideCreator = {
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
videoAttributes.muted = "";
|
|
|
|
videoAttributes.muted = "";
|
|
|
|
videoAttributes.playsinline = ""; // again Safari needs extra treatment...
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
videoBackdrop = SlideUtils.createElement("video", videoAttributes);
|
|
|
|
videoBackdrop = SlideUtils.createElement("video", videoAttributes);
|
|
|
|
videoBackdrop.volume = 0.4;
|
|
|
|
videoBackdrop.volume = 0.4;
|
|
|
|
@@ -2467,58 +2469,42 @@ const SlideshowManager = {
|
|
|
|
if (videoBackdrop.tagName === 'VIDEO') {
|
|
|
|
if (videoBackdrop.tagName === 'VIDEO') {
|
|
|
|
// Restore src from data-src if it was deactivated to release connections
|
|
|
|
// Restore src from data-src if it was deactivated to release connections
|
|
|
|
const lazySrc = videoBackdrop.getAttribute('data-src');
|
|
|
|
const lazySrc = videoBackdrop.getAttribute('data-src');
|
|
|
|
const isFreshLoad = lazySrc && !videoBackdrop.src;
|
|
|
|
if (lazySrc && !videoBackdrop.src) {
|
|
|
|
|
|
|
|
videoBackdrop.src = lazySrc;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
videoBackdrop.currentTime = 0;
|
|
|
|
|
|
|
|
|
|
|
|
videoBackdrop.muted = STATE.slideshow.isMuted;
|
|
|
|
videoBackdrop.muted = STATE.slideshow.isMuted;
|
|
|
|
if (!STATE.slideshow.isMuted) {
|
|
|
|
if (!STATE.slideshow.isMuted) {
|
|
|
|
videoBackdrop.volume = 0.4;
|
|
|
|
videoBackdrop.volume = 0.4;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const doPlay = () => {
|
|
|
|
videoBackdrop.play().catch(e => {
|
|
|
|
if (!currentSlide.classList.contains('active')) return;
|
|
|
|
// Check if it actually started playing after a short delay (handling autoplay blocks)
|
|
|
|
videoBackdrop.play().catch(e => {
|
|
|
|
setTimeout(() => {
|
|
|
|
setTimeout(() => {
|
|
|
|
if (videoBackdrop.paused && currentSlide.classList.contains('active')) {
|
|
|
|
if (videoBackdrop.paused && currentSlide.classList.contains('active')) {
|
|
|
|
console.warn(`Autoplay blocked for ${currentItemId}, attempting muted fallback`);
|
|
|
|
console.warn(`Autoplay blocked for ${currentItemId}, attempting muted fallback`);
|
|
|
|
videoBackdrop.muted = true;
|
|
|
|
videoBackdrop.muted = true;
|
|
|
|
videoBackdrop.play().catch(err => console.error("Muted fallback failed", err));
|
|
|
|
videoBackdrop.play().catch(err => console.error("Muted fallback failed", err));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}, 1000);
|
|
|
|
}, 1000);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (isFreshLoad) {
|
|
|
|
|
|
|
|
// Safari: set src, then wait for loadedmetadata before seeking/playing
|
|
|
|
|
|
|
|
videoBackdrop.src = lazySrc;
|
|
|
|
|
|
|
|
videoBackdrop.load();
|
|
|
|
|
|
|
|
videoBackdrop.addEventListener('loadedmetadata', () => {
|
|
|
|
|
|
|
|
videoBackdrop.currentTime = 0;
|
|
|
|
|
|
|
|
doPlay();
|
|
|
|
|
|
|
|
}, { once: true });
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
// src already set (e.g. paused slide resuming)
|
|
|
|
|
|
|
|
videoBackdrop.currentTime = 0;
|
|
|
|
|
|
|
|
doPlay();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else if (STATE.slideshow.videoPlayers && STATE.slideshow.videoPlayers[currentItemId]) {
|
|
|
|
} else if (STATE.slideshow.videoPlayers && STATE.slideshow.videoPlayers[currentItemId]) {
|
|
|
|
const player = STATE.slideshow.videoPlayers[currentItemId];
|
|
|
|
const player = STATE.slideshow.videoPlayers[currentItemId];
|
|
|
|
if (player && typeof player.loadVideoById === 'function' && player._videoId) {
|
|
|
|
if (player && typeof player.loadVideoById === 'function' && player._videoId) {
|
|
|
|
// Use loadVideoById to enforce start and end times
|
|
|
|
// Use loadVideoById to enforce start and end times
|
|
|
|
// load always starts muted first, then unmute if needed
|
|
|
|
|
|
|
|
player.loadVideoById({
|
|
|
|
player.loadVideoById({
|
|
|
|
videoId: player._videoId,
|
|
|
|
videoId: player._videoId,
|
|
|
|
startSeconds: player._startTime || 0,
|
|
|
|
startSeconds: player._startTime || 0,
|
|
|
|
endSeconds: player._endTime
|
|
|
|
endSeconds: player._endTime
|
|
|
|
});
|
|
|
|
});
|
|
|
|
player.mute();
|
|
|
|
|
|
|
|
if (!STATE.slideshow.isMuted) {
|
|
|
|
if (STATE.slideshow.isMuted) {
|
|
|
|
setTimeout(() => {
|
|
|
|
player.mute();
|
|
|
|
// Only unmute if still on the same slide
|
|
|
|
} else {
|
|
|
|
if (currentSlide.classList.contains('active')) {
|
|
|
|
player.unMute();
|
|
|
|
player.unMute();
|
|
|
|
player.setVolume(40);
|
|
|
|
player.setVolume(40);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}, 600);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Check if playback successfully started, otherwise fallback to muted
|
|
|
|
// Check if playback successfully started, otherwise fallback to muted
|
|
|
|
@@ -2592,7 +2578,7 @@ const SlideshowManager = {
|
|
|
|
STATE.slideshow.isTransitioning = false;
|
|
|
|
STATE.slideshow.isTransitioning = false;
|
|
|
|
|
|
|
|
|
|
|
|
if (previousVisibleSlide) {
|
|
|
|
if (previousVisibleSlide) {
|
|
|
|
const enableAnimations = MediaBarEnhancedSettingsManager.getSetting('slideAnimations', CONFIG.slideAnimationEnabled);
|
|
|
|
const enableAnimations = MediaBarEnhancedSettingsManager.getSetting('slideAnimations', CONFIG.slideAnimationEnabled) && !isLowPowerDevice();
|
|
|
|
if (enableAnimations) {
|
|
|
|
if (enableAnimations) {
|
|
|
|
const prevBackdrop = previousVisibleSlide.querySelector(".backdrop");
|
|
|
|
const prevBackdrop = previousVisibleSlide.querySelector(".backdrop");
|
|
|
|
const prevLogo = previousVisibleSlide.querySelector(".logo");
|
|
|
|
const prevLogo = previousVisibleSlide.querySelector(".logo");
|
|
|
|
@@ -2633,7 +2619,9 @@ const SlideshowManager = {
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
async preloadAdjacentSlides(currentIndex) {
|
|
|
|
async preloadAdjacentSlides(currentIndex) {
|
|
|
|
const totalItems = STATE.slideshow.totalItems;
|
|
|
|
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();
|
|
|
|
const preloadedIds = new Set();
|
|
|
|
|
|
|
|
|
|
|
|
// Preload next slides
|
|
|
|
// Preload next slides
|
|
|
|
|