feat: add intro-skipper

This commit is contained in:
Prayag Prajapati committed 2024-07-18 21:30:02 +05:30
1 parent a240ec7452
commit d077860fbc
10 files changed
+166 -45

No files matched your search

+31
View File
@@ -0,0 +1,31 @@
import { Store } from "@tauri-apps/plugin-store";
const SettingsStore = new Store(".settings.dat");
/**
* settingKey should be of type:
* 'settingDomain.settingKeyName'
*/
export const setSetting = async (settingKey: string, value: boolean) => {
await SettingsStore.set(settingKey, value);
await SettingsStore.save();
};
export const getSetting = async (settingKey: string) => {
const value = await SettingsStore.get(settingKey);
console.log(`${settingKey} - ${value}`);
if (value) return value;
return false;
};
export const allSettings = {
general: [
{
key: "general.enable_skip_intro_outro",
name: "Enable Intro-Skipper plugin",
description:
"Shows a skip button for Intros and End Credit scenes in an episode. Note: this requires jumoog/intro-skipper plugin to be installed on server",
},
],
};
+6 -2
View File
@@ -1,12 +1,11 @@
import type {
BaseItemDto,
BaseItemKind,
MediaProtocol,
MediaStream,
} from "@jellyfin/sdk/lib/generated-client";
import { getMediaInfoApi } from "@jellyfin/sdk/lib/utils/api/media-info-api";
import { create } from "zustand";
import playbackProfile from "../playback-profiles";
import type IntroMediaInfo from "../types/introMediaInfo";
import type subtitlePlaybackInfo from "../types/subtitlePlaybackInfo";
import { useApiInContext } from "./api";
import { playAudio } from "./audioPlayback";
@@ -28,6 +27,7 @@ type PlaybackStore = {
itemDuration: number;
item: BaseItemDto | null;
playsessionId: string | undefined | null;
intro: IntroMediaInfo | undefined;
};
export const usePlaybackStore = create<PlaybackStore>(() => ({
@@ -53,6 +53,7 @@ export const usePlaybackStore = create<PlaybackStore>(() => ({
itemDuration: 0,
item: null,
playsessionId: "",
intro: undefined,
}));
export const playItem = (
@@ -71,6 +72,7 @@ export const playItem = (
mediaSourceId: string | undefined | null,
playsessionId: string | undefined | null,
subtitle: subtitlePlaybackInfo,
intro: IntroMediaInfo | undefined,
) => {
console.log({
itemName,
@@ -88,6 +90,7 @@ export const playItem = (
itemDuration,
item,
playsessionId,
intro,
});
usePlaybackStore.setState({
itemName,
@@ -105,6 +108,7 @@ export const playItem = (
itemDuration,
item,
playsessionId,
intro,
});
setQueue(queue, queueItemIndex);
};
+10
View File
@@ -0,0 +1,10 @@
type IntroMediaInfo = {
EpisodeId: string;
Valid: true;
IntroStart: number;
IntroEnd: number;
ShowSkipPromptAt: number;
HideSkipPromptAt: number;
};
export default IntroMediaInfo
+2
View File
@@ -2,10 +2,12 @@ import type {
BaseItemDtoQueryResult,
PlaybackInfoResponse,
} from "@jellyfin/sdk/lib/generated-client";
import type IntroMediaInfo from "./introMediaInfo";
interface PlayResult {
item: BaseItemDtoQueryResult;
mediaSource: PlaybackInfoResponse;
introInfo: IntroMediaInfo | undefined;
}
export default PlayResult;