Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
64dbc3cfd3 | ||
|
|
c998266dd7 | ||
|
|
9b941e5a77 | ||
|
|
1d70d7166d | ||
|
|
5331f0faf1 | ||
|
|
0508188705 |
@@ -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.4</Version>
|
<Version>1.7.0.6</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>
|
||||||
|
|
||||||
|
|||||||
@@ -1745,7 +1745,21 @@ const SlideCreator = {
|
|||||||
|
|
||||||
if (isSafariWebKit) {
|
if (isSafariWebKit) {
|
||||||
// ── Safari: plain iframe embed ───────────────────────────────────────────
|
// ── Safari: plain iframe embed ───────────────────────────────────────────
|
||||||
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)}`;
|
// Fetch SponsorBlock data and apply as URL params (start= / end=)
|
||||||
|
ApiUtils.fetchSponsorBlockData(videoId).then(segments => {
|
||||||
|
let startParam = '';
|
||||||
|
let endParam = '';
|
||||||
|
if (segments.intro) {
|
||||||
|
startParam = `&start=${Math.ceil(segments.intro[1])}`;
|
||||||
|
console.info(`SponsorBlock (Safari) intro skip: starting at ${Math.ceil(segments.intro[1])}s`);
|
||||||
|
}
|
||||||
|
if (segments.outro) {
|
||||||
|
endParam = `&end=${Math.floor(segments.outro[0])}`;
|
||||||
|
console.info(`SponsorBlock (Safari) outro skip: ending at ${Math.floor(segments.outro[0])}s`);
|
||||||
|
}
|
||||||
|
|
||||||
|
// enablejsapi=1 needed for postMessage commands — does NOT trigger IFrame API handshake
|
||||||
|
const embedUrl = `https://www.youtube-nocookie.com/embed/${videoId}?autoplay=1&mute=1&controls=0&playsinline=1&rel=0&iv_load_policy=3&enablejsapi=1&origin=${encodeURIComponent(window.location.origin)}${startParam}${endParam}`;
|
||||||
|
|
||||||
const ytIframe = document.createElement('iframe');
|
const ytIframe = document.createElement('iframe');
|
||||||
ytIframe.style.cssText = 'width:100%;height:100%;border:0;pointer-events:none;';
|
ytIframe.style.cssText = 'width:100%;height:100%;border:0;pointer-events:none;';
|
||||||
@@ -1758,30 +1772,98 @@ const SlideCreator = {
|
|||||||
// Show immediately — no onStateChange available for plain iframes
|
// Show immediately — no onStateChange available for plain iframes
|
||||||
videoBackdrop.style.opacity = '1';
|
videoBackdrop.style.opacity = '1';
|
||||||
|
|
||||||
// Create a stub player compatible with all slide management code
|
// Helper: send postMessage command to the iframe player
|
||||||
|
const ytCmd = (func, args = []) => {
|
||||||
|
try {
|
||||||
|
ytIframe.contentWindow?.postMessage(
|
||||||
|
JSON.stringify({ event: 'command', func, args }),
|
||||||
|
'https://www.youtube-nocookie.com'
|
||||||
|
);
|
||||||
|
} catch(e) { /* cross-origin access may fail on some iOS versions */ }
|
||||||
|
};
|
||||||
|
|
||||||
|
// YouTube won't send onStateChange events unless we explicitly subscribe.
|
||||||
|
// The IFrame API does this automatically; we must do it manually for plain iframes.
|
||||||
|
const subscribeToYtEvents = () => {
|
||||||
|
try {
|
||||||
|
// Step 1: Announce we're listening
|
||||||
|
ytIframe.contentWindow?.postMessage(
|
||||||
|
JSON.stringify({ event: 'listening' }),
|
||||||
|
'https://www.youtube-nocookie.com'
|
||||||
|
);
|
||||||
|
// Step 2: Subscribe to state change events
|
||||||
|
ytIframe.contentWindow?.postMessage(
|
||||||
|
JSON.stringify({ event: 'command', func: 'addEventListener', args: ['onStateChange'] }),
|
||||||
|
'https://www.youtube-nocookie.com'
|
||||||
|
);
|
||||||
|
} catch(e) {}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Subscribe when iframe has finished loading
|
||||||
|
ytIframe.addEventListener('load', subscribeToYtEvents);
|
||||||
|
|
||||||
|
// Listen for YouTube state changes (video ended → advance slide)
|
||||||
|
const handleYtMessage = (event) => {
|
||||||
|
if (!event.origin.includes('youtube')) return;
|
||||||
|
try {
|
||||||
|
const data = typeof event.data === 'string' ? JSON.parse(event.data) : event.data;
|
||||||
|
|
||||||
|
// Player is ready — re-subscribe in case the first attempt was too early
|
||||||
|
if (data.event === 'onReady') {
|
||||||
|
subscribeToYtEvents();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data.event === 'onStateChange') {
|
||||||
|
console.log(`🍎 Safari YT state: ${data.info} for ${itemId}`);
|
||||||
|
if (data.info === 0) { // 0 = ENDED
|
||||||
|
const slide = document.querySelector(`.slide[data-item-id="${itemId}"]`);
|
||||||
|
if (slide && slide.classList.contains('active')) {
|
||||||
|
SlideshowManager.nextSlide();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch(e) {}
|
||||||
|
};
|
||||||
|
window.addEventListener('message', handleYtMessage);
|
||||||
|
|
||||||
|
// Create a postMessage-based stub compatible with all slide management code
|
||||||
|
// Key: we NEVER clear ytIframe.src — that would break the YouTube session and cause Error 153.
|
||||||
|
// Instead we use postMessage pause/play/seek to control playback state.
|
||||||
STATE.slideshow.videoPlayers[itemId] = {
|
STATE.slideshow.videoPlayers[itemId] = {
|
||||||
_isSafariIframe: true,
|
_isSafariIframe: true,
|
||||||
_iframe: ytIframe,
|
_iframe: ytIframe,
|
||||||
_videoId: videoId,
|
_videoId: videoId,
|
||||||
_embedUrl: embedUrl,
|
_embedUrl: embedUrl,
|
||||||
pauseVideo() { ytIframe.src = ''; },
|
_msgHandler: handleYtMessage,
|
||||||
stopVideo() { ytIframe.src = ''; },
|
pauseVideo() { ytCmd('pauseVideo'); },
|
||||||
playVideo() { if (!ytIframe.src) ytIframe.src = this._embedUrl; },
|
stopVideo() { ytCmd('pauseVideo'); ytCmd('seekTo', [0, true]); },
|
||||||
mute() { /* cannot mute plain iframe mid-play */ },
|
playVideo() { ytCmd('playVideo'); },
|
||||||
unMute() { /* cannot unmute plain iframe mid-play */ },
|
mute() { ytCmd('mute'); },
|
||||||
setVolume() { /* not available */ },
|
unMute() { ytCmd('unMute'); },
|
||||||
|
setVolume(v) { ytCmd('setVolume', [v]); },
|
||||||
getIframe() { return ytIframe; },
|
getIframe() { return ytIframe; },
|
||||||
getPlayerState() { return 1; }, // always report PLAYING so fallback timeouts don't fire
|
getPlayerState() { return 1; }, // approximate: avoids triggering fallback timeouts
|
||||||
loadVideoById({ videoId: vid }) {
|
loadVideoById({ videoId: vid, startSeconds = 0 }) {
|
||||||
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`;
|
if (vid === this._videoId) {
|
||||||
|
// Same video — seek to start and resume. NEVER change src (would cause Error 153).
|
||||||
|
ytCmd('seekTo', [startSeconds, true]);
|
||||||
|
ytCmd('playVideo');
|
||||||
|
} else {
|
||||||
|
// Different video — need a fresh embed URL
|
||||||
|
const url = `https://www.youtube-nocookie.com/embed/${vid}?autoplay=1&mute=1&controls=0&playsinline=1&rel=0&iv_load_policy=3&enablejsapi=1&origin=${encodeURIComponent(window.location.origin)}`;
|
||||||
ytIframe.src = url;
|
ytIframe.src = url;
|
||||||
this._videoId = vid;
|
this._videoId = vid;
|
||||||
this._embedUrl = url;
|
this._embedUrl = url;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
destroy() { ytIframe.remove(); }
|
destroy() {
|
||||||
|
window.removeEventListener('message', this._msgHandler);
|
||||||
|
ytIframe.remove();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
console.log(`🍎 Safari detected — using plain iframe embed for YouTube video ${videoId}`);
|
console.log(`🍎 Safari detected — using plain iframe embed for YouTube video ${videoId}`);
|
||||||
|
});
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// ── Non-Safari: YouTube IFrame API ──────────────────────────────────────
|
// ── Non-Safari: YouTube IFrame API ──────────────────────────────────────
|
||||||
@@ -2567,9 +2649,10 @@ const SlideshowManager = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check if playback successfully started, otherwise fallback to muted
|
// Check if playback successfully started, otherwise fallback to muted
|
||||||
|
// (Only for real YT.Player instances — Safari stub's getPlayerState() always returns 1)
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
if (!currentSlide.classList.contains('active')) return;
|
if (!currentSlide.classList.contains('active')) return;
|
||||||
if (player.getPlayerState &&
|
if (player.getPlayerState && typeof YT !== 'undefined' &&
|
||||||
player.getPlayerState() !== YT.PlayerState.PLAYING &&
|
player.getPlayerState() !== YT.PlayerState.PLAYING &&
|
||||||
player.getPlayerState() !== YT.PlayerState.BUFFERING) {
|
player.getPlayerState() !== YT.PlayerState.BUFFERING) {
|
||||||
console.log("YouTube loadVideoById didn't start playback, retrying muted...");
|
console.log("YouTube loadVideoById didn't start playback, retrying muted...");
|
||||||
|
|||||||
@@ -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.4",
|
"version": "1.7.0.6",
|
||||||
"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.4/Jellyfin.Plugin.MediaBarEnhanced.zip",
|
"sourceUrl": "https://git.mahom03-spacecloud.de/CodeDevMLH/jellyfin-plugin-media-bar-enhanced/releases/download/v1.7.0.6/Jellyfin.Plugin.MediaBarEnhanced.zip",
|
||||||
"checksum": "a8f3cbea12cdce5902212d4ca753eb83",
|
"checksum": "58cb845a803a209362acbc01acc7dacc",
|
||||||
"timestamp": "2026-03-05T23:35:22Z"
|
"timestamp": "2026-03-06T00:25:03Z"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"version": "1.6.6.4",
|
"version": "1.6.6.4",
|
||||||
|
|||||||
Reference in New Issue
Block a user