Compare commits

...

6 Commits

Author SHA1 Message Date
CodeDevMLH
ee8c0b8888 Update manifest.json for release v1.6.1.29 [skip ci] 2026-02-14 15:04:22 +00:00
CodeDevMLH
64ef4915b8 Bump version to 1.6.1.29
All checks were successful
Auto Release Plugin / build-and-release (push) Successful in 53s
2026-02-14 16:03:30 +01:00
CodeDevMLH
1f655ed7b6 Enhance SponsorBlock data fetching with caching and improve slide transition logic 2026-02-14 16:03:14 +01:00
CodeDevMLH
0682967591 Update manifest.json for release v1.6.1.28 [skip ci] 2026-02-14 14:38:41 +00:00
CodeDevMLH
7938728f8e Bump version to 1.6.1.28 in project file and manifest
All checks were successful
Auto Release Plugin / build-and-release (push) Successful in 53s
2026-02-14 15:37:50 +01:00
CodeDevMLH
a0773c66eb Refactor video playback logic to manage mute state more effectively and improve autoplay handling 2026-02-14 15:37:44 +01:00
3 changed files with 88 additions and 41 deletions

View File

@@ -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.6.1.26</Version> <Version>1.6.1.29</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>

View File

@@ -1258,9 +1258,20 @@ const ApiUtils = {
*/ */
async fetchSponsorBlockData(videoId) { async fetchSponsorBlockData(videoId) {
if (!CONFIG.useSponsorBlock) return { intro: null, outro: null }; if (!CONFIG.useSponsorBlock) return { intro: null, outro: null };
// Return cached result if available
if (!this._sponsorBlockCache) this._sponsorBlockCache = {};
if (this._sponsorBlockCache[videoId]) {
return this._sponsorBlockCache[videoId];
}
try { try {
const response = await fetch(`https://sponsor.ajay.app/api/skipSegments?videoID=${videoId}&categories=["intro","outro"]`); const response = await fetch(`https://sponsor.ajay.app/api/skipSegments?videoID=${videoId}&categories=["intro","outro"]`);
if (!response.ok) return { intro: null, outro: null }; if (!response.ok) {
const result = { intro: null, outro: null };
this._sponsorBlockCache[videoId] = result;
return result;
}
const segments = await response.json(); const segments = await response.json();
let intro = null; let intro = null;
@@ -1274,7 +1285,9 @@ const ApiUtils = {
} }
}); });
return { intro, outro }; const result = { intro, outro };
this._sponsorBlockCache[videoId] = result;
return result;
} catch (error) { } catch (error) {
console.warn('Error fetching SponsorBlock data:', error); console.warn('Error fetching SponsorBlock data:', error);
return { intro: null, outro: null }; return { intro: null, outro: null };
@@ -1709,13 +1722,6 @@ const SlideCreator = {
event.target._endTime = playerVars.end || undefined; event.target._endTime = playerVars.end || undefined;
event.target._videoId = videoId; event.target._videoId = videoId;
if (STATE.slideshow.isMuted) {
event.target.mute();
} else {
event.target.unMute();
event.target.setVolume(40);
}
if (typeof event.target.setPlaybackQuality === 'function') { if (typeof event.target.setPlaybackQuality === 'function') {
event.target.setPlaybackQuality(quality); event.target.setPlaybackQuality(quality);
} }
@@ -1725,6 +1731,14 @@ const SlideCreator = {
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'))) {
// Set mute state only for active slide
if (STATE.slideshow.isMuted) {
event.target.mute();
} else {
event.target.unMute();
event.target.setVolume(40);
}
event.target.playVideo(); event.target.playVideo();
// Check if it actually started playing after a short delay (handling autoplay blocks) // Check if it actually started playing after a short delay (handling autoplay blocks)
@@ -1754,11 +1768,20 @@ const SlideCreator = {
if (CONFIG.waitForTrailerToEnd && STATE.slideshow.slideInterval) { if (CONFIG.waitForTrailerToEnd && STATE.slideshow.slideInterval) {
STATE.slideshow.slideInterval.stop(); STATE.slideshow.slideInterval.stop();
} }
} else {
event.target.mute();
} }
}, },
'onStateChange': (event) => { 'onStateChange': (event) => {
if (event.data === YT.PlayerState.ENDED) { if (event.data === YT.PlayerState.ENDED) {
SlideshowManager.nextSlide(); const slide = document.querySelector(`.slide[data-item-id="${itemId}"]`);
if (slide && slide.classList.contains('active')) {
if (CONFIG.waitForTrailerToEnd) {
SlideshowManager.nextSlide();
} else {
event.target.playVideo(); // Loop if trailer is shorter than slide duration
}
}
} }
}, },
'onError': (event) => { 'onError': (event) => {
@@ -2275,35 +2298,42 @@ const SlideshowManager = {
if (previousVisibleSlide) { if (previousVisibleSlide) {
previousVisibleSlide.classList.remove("active"); previousVisibleSlide.classList.remove("active");
previousVisibleSlide.setAttribute("inert", ""); // previousVisibleSlide.setAttribute("inert", "");
previousVisibleSlide.setAttribute("tabindex", "-1"); // previousVisibleSlide.setAttribute("tabindex", "-1");
} }
currentSlide.classList.add("active"); currentSlide.classList.add("active");
currentSlide.removeAttribute("inert"); // currentSlide.removeAttribute("inert");
currentSlide.setAttribute("tabindex", "0"); // currentSlide.setAttribute("tabindex", "0");
// Update Play/Pause Button State if it was paused // // Update Play/Pause Button State if it was paused
if (STATE.slideshow.isPaused) { // if (STATE.slideshow.isPaused) {
STATE.slideshow.isPaused = false; // STATE.slideshow.isPaused = false;
const pauseButton = document.querySelector('.pause-button'); // const pauseButton = document.querySelector('.pause-button');
if (pauseButton) { // if (pauseButton) {
pauseButton.innerHTML = '<i class="material-icons">pause</i>'; // pauseButton.innerHTML = '<i class="material-icons">pause</i>';
const pauseLabel = LocalizationUtils.getLocalizedString('ButtonPause', 'Pause'); // const pauseLabel = LocalizationUtils.getLocalizedString('ButtonPause', 'Pause');
pauseButton.setAttribute("aria-label", pauseLabel); // pauseButton.setAttribute("aria-label", pauseLabel);
pauseButton.setAttribute("title", pauseLabel); // pauseButton.setAttribute("title", pauseLabel);
} // }
} // }
// Manage Video Playback: Stop others, Play current // Manage Video Playback: Stop others, Play current
// 1. Pause all other YouTube players // 1. Pause and mute all other YouTube players
if (STATE.slideshow.videoPlayers) { if (STATE.slideshow.videoPlayers) {
Object.keys(STATE.slideshow.videoPlayers).forEach(id => { Object.keys(STATE.slideshow.videoPlayers).forEach(id => {
if (id !== currentItemId) { if (id !== currentItemId) {
const p = STATE.slideshow.videoPlayers[id]; const p = STATE.slideshow.videoPlayers[id];
if (p && typeof p.pauseVideo === 'function') { if (p) {
p.pauseVideo(); try {
if (typeof p.pauseVideo === 'function') {
p.pauseVideo();
if (typeof p.mute === 'function') {
p.mute();
}
}
} catch (e) { console.warn("Error pausing player", id, e); }
} }
} }
}); });
@@ -2339,8 +2369,8 @@ const SlideshowManager = {
videoBackdrop.play().catch(e => { videoBackdrop.play().catch(e => {
// Check if it actually started playing after a short delay (handling autoplay blocks) // Check if it actually started playing after a short delay (handling autoplay blocks)
setTimeout(() => { setTimeout(() => {
if (videoBackdrop.paused) { if (videoBackdrop.paused && currentSlide.classList.contains('active')) {
console.warn(`Autoplay blocked for ${itemId}, 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));
} }
@@ -2349,12 +2379,28 @@ const SlideshowManager = {
} 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 // If same video is already loaded, just seek and play (much faster)
player.loadVideoById({ let isAlreadyLoaded = false;
videoId: player._videoId, if (typeof player.getVideoData === 'function') {
startSeconds: player._startTime || 0, try {
endSeconds: player._endTime const data = player.getVideoData();
}); if (data && data.video_id === player._videoId) {
isAlreadyLoaded = true;
}
} catch (e) { /* player not fully ready */ }
}
if (isAlreadyLoaded) {
player.seekTo(player._startTime || 0);
player.playVideo();
} else {
// Full load needed (first time or different video)
player.loadVideoById({
videoId: player._videoId,
startSeconds: player._startTime || 0,
endSeconds: player._endTime
});
}
if (STATE.slideshow.isMuted) { if (STATE.slideshow.isMuted) {
player.mute(); player.mute();
@@ -2365,6 +2411,7 @@ const SlideshowManager = {
// Check if playback successfully started, otherwise fallback to muted // Check if playback successfully started, otherwise fallback to muted
setTimeout(() => { setTimeout(() => {
if (!currentSlide.classList.contains('active')) return;
if (player.getPlayerState && if (player.getPlayerState &&
player.getPlayerState() !== YT.PlayerState.PLAYING && player.getPlayerState() !== YT.PlayerState.PLAYING &&
player.getPlayerState() !== YT.PlayerState.BUFFERING) { player.getPlayerState() !== YT.PlayerState.BUFFERING) {

View File

@@ -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.6.1.27", "version": "1.6.1.29",
"changelog": "- fix tv mode issue\n- refactor video playback management", "changelog": "- fix tv mode issue\n- refactor video playback management",
"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.6.1.27/Jellyfin.Plugin.MediaBarEnhanced.zip", "sourceUrl": "https://git.mahom03-spacecloud.de/CodeDevMLH/jellyfin-plugin-media-bar-enhanced/releases/download/v1.6.1.29/Jellyfin.Plugin.MediaBarEnhanced.zip",
"checksum": "44b532e881c7ed128d6e76e387f41710", "checksum": "6bdae85c590e90948a79984b56f93fa0",
"timestamp": "2026-02-14T14:22:58Z" "timestamp": "2026-02-14T15:04:20Z"
}, },
{ {
"version": "1.6.0.2", "version": "1.6.0.2",