Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
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.5</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,69 @@ 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 */ }
|
||||||
|
};
|
||||||
|
|
||||||
|
// Listen for YouTube state changes (e.g. 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;
|
||||||
|
if (data.event === 'onStateChange' && data.info === 0) { // 0 = YT.PlayerState.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 ──────────────────────────────────────
|
||||||
|
|||||||
@@ -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.5",
|
||||||
"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.5/Jellyfin.Plugin.MediaBarEnhanced.zip",
|
||||||
"checksum": "a8f3cbea12cdce5902212d4ca753eb83",
|
"checksum": "2d7e4d747c610e853b375726162febee",
|
||||||
"timestamp": "2026-03-05T23:35:22Z"
|
"timestamp": "2026-03-05T23:59:05Z"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"version": "1.6.6.4",
|
"version": "1.6.6.4",
|
||||||
|
|||||||
Reference in New Issue
Block a user