Compare commits
4 Commits
d0c3d7ee4d
...
v1.7.0.4
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cc861f4263 | ||
|
|
10e6cdc4a2 | ||
|
|
a8c7faab6b | ||
|
|
6df390fa18 |
@@ -12,7 +12,7 @@
|
|||||||
<!-- <TreatWarningsAsErrors>false</TreatWarningsAsErrors> -->
|
<!-- <TreatWarningsAsErrors>false</TreatWarningsAsErrors> -->
|
||||||
<Title>Jellyfin Media Bar Enhanced Plugin</Title>
|
<Title>Jellyfin Media Bar Enhanced Plugin</Title>
|
||||||
<Authors>CodeDevMLH</Authors>
|
<Authors>CodeDevMLH</Authors>
|
||||||
<Version>1.7.0.3</Version>
|
<Version>1.7.0.4</Version>
|
||||||
<RepositoryUrl>https://github.com/CodeDevMLH/jellyfin-plugin-media-bar-enhanced</RepositoryUrl>
|
<RepositoryUrl>https://github.com/CodeDevMLH/jellyfin-plugin-media-bar-enhanced</RepositoryUrl>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
|||||||
@@ -1736,155 +1736,193 @@ const SlideCreator = {
|
|||||||
// Create a wrapper for opacity transition
|
// Create a wrapper for opacity transition
|
||||||
videoBackdrop = SlideUtils.createElement("div", {
|
videoBackdrop = SlideUtils.createElement("div", {
|
||||||
className: `backdrop video-backdrop ${videoClass}`,
|
className: `backdrop video-backdrop ${videoClass}`,
|
||||||
style: "opacity: 0; transition: opacity 1.2s ease-in-out;" // Start interrupted/transparent
|
style: "opacity: 0; transition: opacity 1.2s ease-in-out;"
|
||||||
});
|
});
|
||||||
|
|
||||||
const ytPlayerDiv = SlideUtils.createElement("div", {
|
// Detect Safari/WebKit — the YouTube IFrame API causes Error 153 on WebKit
|
||||||
id: `youtube-player-${itemId}`,
|
// due to cross-origin postMessage restrictions. Use a plain iframe embed instead.
|
||||||
style: "width: 100%; height: 100%;"
|
const isSafariWebKit = /Safari/.test(navigator.userAgent) && !/Chrome/.test(navigator.userAgent) && !/Chromium/.test(navigator.userAgent);
|
||||||
});
|
|
||||||
|
|
||||||
videoBackdrop.appendChild(ytPlayerDiv);
|
|
||||||
|
|
||||||
// Initialize YouTube Player
|
if (isSafariWebKit) {
|
||||||
SlideUtils.loadYouTubeIframeAPI().then(() => {
|
// ── Safari: plain iframe embed ───────────────────────────────────────────
|
||||||
// Fetch SponsorBlock data
|
const embedUrl = `https://www.youtube-nocookie.com/embed/${videoId}?autoplay=1&mute=1&controls=0&playsinline=1&rel=0&iv_load_policy=3&enablejsapi=0&origin=${encodeURIComponent(window.location.origin)}`;
|
||||||
ApiUtils.fetchSponsorBlockData(videoId).then(segments => {
|
|
||||||
const playerVars = {
|
|
||||||
autoplay: 1,
|
|
||||||
mute: 1, // need to be muted for Safari, because apple makes life difficult...
|
|
||||||
controls: 0,
|
|
||||||
disablekb: 1,
|
|
||||||
fs: 0,
|
|
||||||
iv_load_policy: 3,
|
|
||||||
rel: 0,
|
|
||||||
loop: 0,
|
|
||||||
playsinline: 1,
|
|
||||||
origin: window.location.origin,
|
|
||||||
enablejsapi: 1
|
|
||||||
};
|
|
||||||
|
|
||||||
// Determine video quality
|
const ytIframe = document.createElement('iframe');
|
||||||
let quality = 'hd1080';
|
ytIframe.style.cssText = 'width:100%;height:100%;border:0;pointer-events:none;';
|
||||||
if (CONFIG.preferredVideoQuality === 'Maximum') {
|
ytIframe.setAttribute('allow', 'accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share');
|
||||||
quality = 'highres';
|
ytIframe.setAttribute('allowfullscreen', '');
|
||||||
} else if (CONFIG.preferredVideoQuality === '720p') {
|
ytIframe.setAttribute('referrerpolicy', 'strict-origin-when-cross-origin');
|
||||||
quality = 'hd720';
|
ytIframe.src = embedUrl;
|
||||||
} else if (CONFIG.preferredVideoQuality === '1080p') {
|
videoBackdrop.appendChild(ytIframe);
|
||||||
quality = 'hd1080';
|
|
||||||
} else { // Auto or fallback
|
|
||||||
// If screen is wider than 1920, prefer highres, otherwise 1080p
|
|
||||||
quality = window.screen.width > 1920 ? 'highres' : 'hd1080';
|
|
||||||
}
|
|
||||||
|
|
||||||
playerVars.suggestedQuality = quality;
|
// Show immediately — no onStateChange available for plain iframes
|
||||||
|
videoBackdrop.style.opacity = '1';
|
||||||
|
|
||||||
// Apply SponsorBlock start/end times
|
// Create a stub player compatible with all slide management code
|
||||||
if (segments.intro) {
|
STATE.slideshow.videoPlayers[itemId] = {
|
||||||
playerVars.start = Math.ceil(segments.intro[1]);
|
_isSafariIframe: true,
|
||||||
console.info(`SponsorBlock intro detected for video ${videoId}: skipping to ${playerVars.start}s`);
|
_iframe: ytIframe,
|
||||||
}
|
_videoId: videoId,
|
||||||
if (segments.outro) {
|
_embedUrl: embedUrl,
|
||||||
playerVars.end = Math.floor(segments.outro[0]);
|
pauseVideo() { ytIframe.src = ''; },
|
||||||
console.info(`SponsorBlock outro detected for video ${videoId}: ending at ${playerVars.end}s`);
|
stopVideo() { ytIframe.src = ''; },
|
||||||
}
|
playVideo() { if (!ytIframe.src) ytIframe.src = this._embedUrl; },
|
||||||
|
mute() { /* cannot mute plain iframe mid-play */ },
|
||||||
|
unMute() { /* cannot unmute plain iframe mid-play */ },
|
||||||
|
setVolume() { /* not available */ },
|
||||||
|
getIframe() { return ytIframe; },
|
||||||
|
getPlayerState() { return 1; }, // always report PLAYING so fallback timeouts don't fire
|
||||||
|
loadVideoById({ videoId: vid }) {
|
||||||
|
const url = `https://www.youtube-nocookie.com/embed/${vid}?autoplay=1&mute=1&controls=0&playsinline=1&rel=0&iv_load_policy=3&enablejsapi=0`;
|
||||||
|
ytIframe.src = url;
|
||||||
|
this._videoId = vid;
|
||||||
|
this._embedUrl = url;
|
||||||
|
},
|
||||||
|
destroy() { ytIframe.remove(); }
|
||||||
|
};
|
||||||
|
|
||||||
STATE.slideshow.videoPlayers[itemId] = new YT.Player(`youtube-player-${itemId}`, {
|
console.log(`🍎 Safari detected — using plain iframe embed for YouTube video ${videoId}`);
|
||||||
height: '100%',
|
|
||||||
width: '100%',
|
|
||||||
videoId: videoId,
|
|
||||||
host: 'https://www.youtube-nocookie.com',
|
|
||||||
playerVars: playerVars,
|
|
||||||
events: {
|
|
||||||
'onReady': (event) => {
|
|
||||||
const iframe = event.target.getIframe();
|
|
||||||
if (iframe) {
|
|
||||||
iframe.setAttribute('referrerpolicy', 'strict-origin-when-cross-origin');
|
|
||||||
// Full allow attribute matching what YouTube sets on their own embed pages
|
|
||||||
iframe.setAttribute('allow', 'accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share');
|
|
||||||
}
|
|
||||||
|
|
||||||
// Store start/end time and videoId for later use
|
} else {
|
||||||
event.target._startTime = playerVars.start || 0;
|
// ── Non-Safari: YouTube IFrame API ──────────────────────────────────────
|
||||||
event.target._endTime = playerVars.end || undefined;
|
const ytPlayerDiv = SlideUtils.createElement("div", {
|
||||||
event.target._videoId = videoId;
|
id: `youtube-player-${itemId}`,
|
||||||
|
style: "width: 100%; height: 100%;"
|
||||||
// Store reference to wrapper for fading
|
});
|
||||||
event.target._wrapperDiv = videoBackdrop;
|
|
||||||
|
|
||||||
// Unmute now if user wants sound.
|
videoBackdrop.appendChild(ytPlayerDiv);
|
||||||
if (!STATE.slideshow.isMuted) {
|
|
||||||
event.target.unMute();
|
|
||||||
event.target.setVolume(40);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (typeof event.target.setPlaybackQuality === 'function') {
|
SlideUtils.loadYouTubeIframeAPI().then(() => {
|
||||||
event.target.setPlaybackQuality(quality);
|
ApiUtils.fetchSponsorBlockData(videoId).then(segments => {
|
||||||
}
|
const playerVars = {
|
||||||
|
autoplay: 1,
|
||||||
|
mute: 1, // need to be muted for Safari, because apple makes life difficult...
|
||||||
|
controls: 0,
|
||||||
|
disablekb: 1,
|
||||||
|
fs: 0,
|
||||||
|
iv_load_policy: 3,
|
||||||
|
rel: 0,
|
||||||
|
loop: 0,
|
||||||
|
playsinline: 1,
|
||||||
|
origin: window.location.origin,
|
||||||
|
enablejsapi: 1
|
||||||
|
};
|
||||||
|
|
||||||
// Stop playback if slide was navigated away from
|
// Determine video quality
|
||||||
const slide = document.querySelector(`.slide[data-item-id="${itemId}"]`);
|
let quality = 'hd1080';
|
||||||
const isVideoPlayerOpen = document.querySelector('.videoPlayerContainer') || document.querySelector('.youtubePlayerContainer');
|
if (CONFIG.preferredVideoQuality === 'Maximum') {
|
||||||
|
quality = 'highres';
|
||||||
|
} else if (CONFIG.preferredVideoQuality === '720p') {
|
||||||
|
quality = 'hd720';
|
||||||
|
} else if (CONFIG.preferredVideoQuality === '1080p') {
|
||||||
|
quality = 'hd1080';
|
||||||
|
} else {
|
||||||
|
quality = window.screen.width > 1920 ? 'highres' : 'hd1080';
|
||||||
|
}
|
||||||
|
|
||||||
if (!slide || !slide.classList.contains('active') || document.hidden || (isVideoPlayerOpen && !isVideoPlayerOpen.classList.contains('hide'))) {
|
playerVars.suggestedQuality = quality;
|
||||||
event.target.stopVideo();
|
|
||||||
} else {
|
// Apply SponsorBlock start/end times
|
||||||
// Pause slideshow timer when video starts if configured
|
if (segments.intro) {
|
||||||
if (CONFIG.waitForTrailerToEnd && STATE.slideshow.slideInterval) {
|
playerVars.start = Math.ceil(segments.intro[1]);
|
||||||
STATE.slideshow.slideInterval.stop();
|
console.info(`SponsorBlock intro detected for video ${videoId}: skipping to ${playerVars.start}s`);
|
||||||
|
}
|
||||||
|
if (segments.outro) {
|
||||||
|
playerVars.end = Math.floor(segments.outro[0]);
|
||||||
|
console.info(`SponsorBlock outro detected for video ${videoId}: ending at ${playerVars.end}s`);
|
||||||
|
}
|
||||||
|
|
||||||
|
STATE.slideshow.videoPlayers[itemId] = new YT.Player(`youtube-player-${itemId}`, {
|
||||||
|
height: '100%',
|
||||||
|
width: '100%',
|
||||||
|
videoId: videoId,
|
||||||
|
host: 'https://www.youtube-nocookie.com',
|
||||||
|
playerVars: playerVars,
|
||||||
|
events: {
|
||||||
|
'onReady': (event) => {
|
||||||
|
const iframe = event.target.getIframe();
|
||||||
|
if (iframe) {
|
||||||
|
iframe.setAttribute('referrerpolicy', 'strict-origin-when-cross-origin');
|
||||||
|
// Full allow attribute matching what YouTube sets on their own embed pages
|
||||||
|
iframe.setAttribute('allow', 'accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Safety check after 1s: handle navigation-away during the window,
|
// Store start/end time and videoId for later use
|
||||||
// and fallback to muted play if autoplay failed for any reason.
|
event.target._startTime = playerVars.start || 0;
|
||||||
const timeoutId = setTimeout(() => {
|
event.target._endTime = playerVars.end || undefined;
|
||||||
const isVideoPlayerOpenNow = document.querySelector('.videoPlayerContainer') || document.querySelector('.youtubePlayerContainer');
|
event.target._videoId = videoId;
|
||||||
if (document.hidden || (isVideoPlayerOpenNow && !isVideoPlayerOpenNow.classList.contains('hide')) || !slide.classList.contains('active')) {
|
|
||||||
console.log(`Navigation detected during autoplay check for ${itemId}, stopping video.`);
|
|
||||||
try {
|
|
||||||
event.target.stopVideo();
|
|
||||||
} catch (e) { console.warn("Error stopping video:", e); }
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// If somehow not playing/buffering yet, force muted fallback
|
// Store reference to wrapper for fading
|
||||||
const state = event.target.getPlayerState();
|
event.target._wrapperDiv = videoBackdrop;
|
||||||
if (state !== YT.PlayerState.PLAYING && state !== YT.PlayerState.BUFFERING) {
|
|
||||||
console.warn(`Autoplay stalled for ${itemId}, attempting muted fallback`);
|
|
||||||
event.target.mute();
|
|
||||||
event.target.playVideo();
|
|
||||||
}
|
|
||||||
}, 1000);
|
|
||||||
|
|
||||||
if (!STATE.slideshow.autoplayTimeouts) STATE.slideshow.autoplayTimeouts = [];
|
// Unmute now if user wants sound.
|
||||||
STATE.slideshow.autoplayTimeouts.push(timeoutId);
|
if (!STATE.slideshow.isMuted) {
|
||||||
}
|
event.target.unMute();
|
||||||
},
|
event.target.setVolume(40);
|
||||||
'onStateChange': (event) => {
|
}
|
||||||
// Fade in when playing
|
|
||||||
if (event.data === YT.PlayerState.PLAYING) {
|
if (typeof event.target.setPlaybackQuality === 'function') {
|
||||||
if (event.target._wrapperDiv) {
|
event.target.setPlaybackQuality(quality);
|
||||||
event.target._wrapperDiv.style.opacity = "1";
|
}
|
||||||
}
|
|
||||||
}
|
// Stop playback if slide was navigated away from
|
||||||
|
|
||||||
if (event.data === YT.PlayerState.ENDED) {
|
|
||||||
const slide = document.querySelector(`.slide[data-item-id="${itemId}"]`);
|
const slide = document.querySelector(`.slide[data-item-id="${itemId}"]`);
|
||||||
if (slide && slide.classList.contains('active')) {
|
const isVideoPlayerOpen = document.querySelector('.videoPlayerContainer') || document.querySelector('.youtubePlayerContainer');
|
||||||
|
|
||||||
|
if (!slide || !slide.classList.contains('active') || document.hidden || (isVideoPlayerOpen && !isVideoPlayerOpen.classList.contains('hide'))) {
|
||||||
|
event.target.stopVideo();
|
||||||
|
} else {
|
||||||
|
if (CONFIG.waitForTrailerToEnd && STATE.slideshow.slideInterval) {
|
||||||
|
STATE.slideshow.slideInterval.stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
const timeoutId = setTimeout(() => {
|
||||||
|
const isVideoPlayerOpenNow = document.querySelector('.videoPlayerContainer') || document.querySelector('.youtubePlayerContainer');
|
||||||
|
if (document.hidden || (isVideoPlayerOpenNow && !isVideoPlayerOpenNow.classList.contains('hide')) || !slide.classList.contains('active')) {
|
||||||
|
console.log(`Navigation detected during autoplay check for ${itemId}, stopping video.`);
|
||||||
|
try {
|
||||||
|
event.target.stopVideo();
|
||||||
|
} catch (e) { console.warn("Error stopping video:", e); }
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const state = event.target.getPlayerState();
|
||||||
|
if (state !== YT.PlayerState.PLAYING && state !== YT.PlayerState.BUFFERING) {
|
||||||
|
console.warn(`Autoplay stalled for ${itemId}, attempting muted fallback`);
|
||||||
|
event.target.mute();
|
||||||
|
event.target.playVideo();
|
||||||
|
}
|
||||||
|
}, 1000);
|
||||||
|
|
||||||
|
if (!STATE.slideshow.autoplayTimeouts) STATE.slideshow.autoplayTimeouts = [];
|
||||||
|
STATE.slideshow.autoplayTimeouts.push(timeoutId);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
'onStateChange': (event) => {
|
||||||
|
if (event.data === YT.PlayerState.PLAYING) {
|
||||||
|
if (event.target._wrapperDiv) {
|
||||||
|
event.target._wrapperDiv.style.opacity = "1";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (event.data === YT.PlayerState.ENDED) {
|
||||||
|
const slide = document.querySelector(`.slide[data-item-id="${itemId}"]`);
|
||||||
|
if (slide && slide.classList.contains('active')) {
|
||||||
|
SlideshowManager.nextSlide();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
'onError': (event) => {
|
||||||
|
console.warn(`YouTube player error ${event.data} for video ${videoId}`);
|
||||||
|
if (CONFIG.waitForTrailerToEnd) {
|
||||||
SlideshowManager.nextSlide();
|
SlideshowManager.nextSlide();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
|
||||||
'onError': (event) => {
|
|
||||||
console.warn(`YouTube player error ${event.data} for video ${videoId}`);
|
|
||||||
// Fallback to next slide on error
|
|
||||||
if (CONFIG.waitForTrailerToEnd) {
|
|
||||||
SlideshowManager.nextSlide();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
} // end non-Safari
|
||||||
|
|
||||||
// 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) {
|
||||||
|
|||||||
@@ -9,12 +9,12 @@
|
|||||||
"imageUrl": "https://git.mahom03-spacecloud.de/CodeDevMLH/jellyfin-plugin-media-bar-enhanced/raw/branch/main/logo.png",
|
"imageUrl": "https://git.mahom03-spacecloud.de/CodeDevMLH/jellyfin-plugin-media-bar-enhanced/raw/branch/main/logo.png",
|
||||||
"versions": [
|
"versions": [
|
||||||
{
|
{
|
||||||
"version": "1.7.0.3",
|
"version": "1.7.0.4",
|
||||||
"changelog": "- Add YouTube no-cookie host and referrer policy for iframe security to fix playback issues on iOS/MacOS",
|
"changelog": "- Add YouTube no-cookie host and referrer policy for iframe security to fix playback issues on iOS/MacOS",
|
||||||
"targetAbi": "10.11.0.0",
|
"targetAbi": "10.11.0.0",
|
||||||
"sourceUrl": "https://git.mahom03-spacecloud.de/CodeDevMLH/jellyfin-plugin-media-bar-enhanced/releases/download/v1.7.0.2/Jellyfin.Plugin.MediaBarEnhanced.zip",
|
"sourceUrl": "https://git.mahom03-spacecloud.de/CodeDevMLH/jellyfin-plugin-media-bar-enhanced/releases/download/v1.7.0.4/Jellyfin.Plugin.MediaBarEnhanced.zip",
|
||||||
"checksum": "ac29b647173ef306beb01f3f66373c21",
|
"checksum": "a8f3cbea12cdce5902212d4ca753eb83",
|
||||||
"timestamp": "2026-03-05T22:44:55Z"
|
"timestamp": "2026-03-05T23:35:22Z"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"version": "1.6.6.4",
|
"version": "1.6.6.4",
|
||||||
|
|||||||
Reference in New Issue
Block a user