Skip to content

Commit

Permalink
Merge branch 'jellyfin:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
siedenburg2 authored May 18, 2024
2 parents 13ead8f + 1ca6cb8 commit 50ca089
Show file tree
Hide file tree
Showing 6 changed files with 121 additions and 49 deletions.
8 changes: 4 additions & 4 deletions CMakeModules/VersionConfiguration.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ endif()

set(VERSION_MAJOR 1)
set(VERSION_MINOR 10)
set(VERSION_NANO 0)
set(VERSION_NANO 1)

option(UPGRADE_DEBUG "" OFF)

set(VERSION_STRING "1.10.0")
set(VERSION_STRING_SHORT "1.10.0")
set(CANONICAL_VERSION_STRING "1.10.0")
set(VERSION_STRING "1.10.1")
set(VERSION_STRING_SHORT "1.10.1")
set(CANONICAL_VERSION_STRING "1.10.1")

configure_file(src/core/Version.cpp.in src/core/Version.cpp)
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ This file can also be printed at runtime when using the ``--licenses`` option.

## Unofficial Plugin Support

You can enable experimental support for [Skip Intro](https://github.com/ConfusedPolarBear/intro-skipper) in client settings. These are included for convenience only and is not an endorsement or long-term commitment to ensure functionality. See `src/native` for details on what the plugins modify code-wise.
You can enable experimental support for [Skip Intro](https://github.com/jumoog/intro-skipper/) in client settings. These are included for convenience only and is not an endorsement or long-term commitment to ensure functionality. See `src/native` for details on what the plugins modify code-wise.

## Known Issues

Expand Down
9 changes: 9 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
jellyfin-media-player (1.10.1-1) unstable; urgency=medium

* Upgrade jellyfin-web to 10.9.2.
* Fix overscroll and inability to launch on MacOS (#628)
* Update skip intro plugin.
* Fix setBackdropTransparency.

-- Izzie Walton <[email protected]> Fri, 17 May 2024 18:20:16 -0400

jellyfin-media-player (1.10.0-1) unstable; urgency=medium

* Update web client to 10.9.1.
Expand Down
9 changes: 3 additions & 6 deletions native/mpvVideoPlayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@
this.appHost = appHost;
this.appSettings = appSettings;

// this can be removed after 10.9
this.setTransparency = (dashboard && dashboard.setBackdropTransparency)
? dashboard.setBackdropTransparency.bind(dashboard)
: appRouter.setTransparency.bind(appRouter);
this.setTransparency = dashboard.default.setBackdropTransparency.bind(dashboard);

/**
* @type {string}
Expand All @@ -39,7 +36,7 @@
* @type {boolean}
*/
this.isFetching = false;

/**
* @type {HTMLDivElement | null | undefined}
*/
Expand Down Expand Up @@ -539,7 +536,7 @@
player.finished.connect(this.onEnded);
player.updateDuration.connect(this.onDuration);
player.error.connect(this.onError);
player.paused.connect(this.onPause);
player.paused.connect(this.onPause);
}

if (options.fullscreen) {
Expand Down
131 changes: 93 additions & 38 deletions native/skipIntroPlugin.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
let tvIntro;
let currentSegment;
let currentPlayer;
let skipIntroConfig;

class skipIntroPlugin {
constructor({ events, playbackManager, ServerConnections }) {
Expand All @@ -14,6 +17,7 @@ class skipIntroPlugin {
if (!enabled) return;

// Based on https://github.com/jellyfin/jellyfin-web/compare/release-10.8.z...ConfusedPolarBear:jellyfin-web:intros
// Updated from https://github.com/jumoog/intro-skipper/blob/master/ConfusedPolarBear.Plugin.IntroSkipper/Configuration/inject.js
// Adapted for use in JMP
const stylesheet = `
<style>
Expand All @@ -23,7 +27,7 @@ class skipIntroPlugin {
background-color:rgba(47,93,98,0) !important;
}
}
.skipIntro {
padding: 0 1px;
position: absolute;
Expand All @@ -39,13 +43,13 @@ class skipIntroPlugin {
-moz-transition: ease-out 0.4s;
transition: ease-out 0.4s;
}
@media (max-width: 1080px) {
.skipIntro {
right: 10%;
}
}
.skipIntro:hover {
box-shadow: inset 400px 0 0 0 #f9f9f9;
-webkit-transition: ease-in 1s;
Expand All @@ -61,7 +65,7 @@ class skipIntroPlugin {
const skipIntroHtml = `
<div class="skipIntro hide">
<button is="paper-icon-button-light" class="btnSkipIntro paper-icon-button-light">
Skip Intro
<span id="btnSkipSegmentText"></span>
<span class="material-icons skip_next"></span>
</button>
</div>
Expand All @@ -87,50 +91,100 @@ class skipIntroPlugin {
function handleClick(e) {
e.preventDefault();
e.stopPropagation();
skipIntro();
doSkip();
document.querySelector('.skipIntro .btnSkipIntro').removeEventListener('click', handleClick, { useCapture: true });
}

function secureFetch(url) {
const apiClient = ServerConnections
? ServerConnections.currentApiClient()
: window.ApiClient;
const address = apiClient.serverAddress();

const reqInit = {
headers: {
"Authorization": `MediaBrowser Token=${apiClient.accessToken()}`
}
};

return fetch(`${address}${url}`, reqInit).then(r => {
if (!r.ok) {
tvIntro = null;
return;
}

return r.json();
});
}

async function injectSkipIntroHtml() {
const playerContainer = await waitForElement('.upNextContainer', 5000);
// inject only if it doesn't exist
if (!document.querySelector('.skipIntro .btnSkipIntro')) {
playerContainer.insertAdjacentHTML('afterend', skipIntroHtml);

skipIntroConfig = await secureFetch("/Intros/UserInterfaceConfiguration");
if (!skipIntroConfig.SkipButtonVisible) {
console.info("[intro skipper] Skip button is disabled by the server.");
return;
}
}

document.querySelector('.skipIntro .btnSkipIntro').addEventListener('click', handleClick, { useCapture: true });
const button = document.querySelector('.skipIntro .btnSkipIntro');
button.addEventListener('click', handleClick, { useCapture: true });

if (window.PointerEvent) {
document.querySelector('.skipIntro .btnSkipIntro').addEventListener('pointerdown', (e) => {
button.addEventListener('pointerdown', (e) => {
e.preventDefault();
e.stopPropagation();
}, { useCapture: true });
}
}


function onPlayback(e, player, state) {
if (state.NowPlayingItem) {
getIntroTimestamps(state.NowPlayingItem);

const onTimeUpdate = async () => {
// Check if an introduction sequence was detected for this item.
if (!tvIntro?.Valid) {
if (!tvIntro) {
return;
}

const seconds = playbackManager.currentTime(player) / 1000;

await injectSkipIntroHtml(); // I have trust issues
const skipIntro = document.querySelector(".skipIntro");

// If the skip prompt should be shown, show it.
if (seconds >= tvIntro.ShowSkipPromptAt && seconds < tvIntro.HideSkipPromptAt) {
skipIntro.classList.remove("hide");
if (!skipIntro) {
return;
}

skipIntro.classList.add("hide");
const segment = getCurrentSegment(playbackManager.currentTime(player) / 1000);
currentSegment = segment;
currentPlayer = player;
switch (segment["SegmentType"]) {
case "None":
if (skipIntro.style.opacity === '0') return;

skipIntro.style.opacity = '0';
skipIntro.addEventListener("transitionend", () => {
skipIntro.classList.add("hide");
}, { once: true });
return;
case "Introduction":
skipIntro.querySelector("#btnSkipSegmentText").textContent = skipIntroConfig.SkipButtonIntroText;
break;
case "Credits":
skipIntro.querySelector("#btnSkipSegmentText").textContent = skipIntroConfig.SkipButtonEndCreditsText;
break;
}
if (!skipIntro.classList.contains("hide")) return;

skipIntro.classList.remove("hide");
requestAnimationFrame(() => {
requestAnimationFrame(() => {
skipIntro.style.opacity = '1';
});
});
};

events.on(player, 'timeupdate', onTimeUpdate);
Expand All @@ -143,36 +197,37 @@ class skipIntroPlugin {
}
};
events.on(playbackManager, 'playbackstart', onPlayback);


function getIntroTimestamps(item) {
const apiClient = ServerConnections
? ServerConnections.currentApiClient()
: window.ApiClient;
const address = apiClient.serverAddress();
secureFetch(`/Episode/${item.Id}/IntroSkipperSegments`).then(intro => {
tvIntro = intro;
}).catch(err => { tvIntro = null; });
}

const url = `${address}/Episode/${item.Id}/IntroTimestamps`;
const reqInit = {
headers: {
"Authorization": `MediaBrowser Token=${apiClient.accessToken()}`
}
};
function osdVisible() {
const osd = document.querySelector("div.videoOsdBottom");
return osd ? !osd.classList.contains("hide") : false;
}

fetch(url, reqInit).then(r => {
if (!r.ok) {
tvIntro = null;
return;
function getCurrentSegment(position) {
for (let key in tvIntro) {
const segment = tvIntro[key];
if ((position >= segment.ShowSkipPromptAt && position < segment.HideSkipPromptAt) || (osdVisible() && position >= segment.IntroStart && position < segment.IntroEnd)) {
segment["SegmentType"] = key;
return segment;
}

return r.json();
}).then(intro => {
tvIntro = intro;
}).catch(err => { tvIntro = null; });
}
return { "SegmentType": "None" };
}

function skipIntro() {
playbackManager.seekMs(tvIntro.IntroEnd * 1000);
function doSkip(e) {
if (currentSegment["SegmentType"] === "None") {
console.warn("[intro skipper] doSkip() called without an active segment");
return;
}
currentPlayer.currentTime(currentSegment["IntroEnd"] * 1000);
}

})();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,17 @@
<category>TV</category>
</categories>
<releases>
<release version="1.10.1" date="2024-05-17">
<description>
<p>Changes:</p>
<ul>
<li>Upgrade jellyfin-web to 10.9.2.</li>
<li>Fix overscroll and inability to launch on MacOS (#628)</li>
<li>Update skip intro plugin.</li>
<li>Fix setBackdropTransparency.</li>
</ul>
</description>
</release>
<release version="1.10.0" date="2024-05-13">
<description>
<p>Changes:</p>
Expand Down

0 comments on commit 50ca089

Please sign in to comment.