mirror of
https://github.com/movie-web/movie-web.git
synced 2025-02-09 09:13:27 +01:00
start at beginning when pressing next episode button
This commit is contained in:
parent
65d0218f81
commit
b39ef2c31f
@ -50,6 +50,9 @@ export function NextEpisodeButton(props: {
|
|||||||
const time = usePlayerStore((s) => s.progress.time);
|
const time = usePlayerStore((s) => s.progress.time);
|
||||||
const showingState = shouldShowNextEpisodeButton(time, duration);
|
const showingState = shouldShowNextEpisodeButton(time, duration);
|
||||||
const status = usePlayerStore((s) => s.status);
|
const status = usePlayerStore((s) => s.status);
|
||||||
|
const setShouldStartFromBeginning = usePlayerStore(
|
||||||
|
(s) => s.setShouldStartFromBeginning
|
||||||
|
);
|
||||||
|
|
||||||
let show = false;
|
let show = false;
|
||||||
if (showingState === "always") show = true;
|
if (showingState === "always") show = true;
|
||||||
@ -69,9 +72,10 @@ export function NextEpisodeButton(props: {
|
|||||||
if (!meta || !nextEp) return;
|
if (!meta || !nextEp) return;
|
||||||
const metaCopy = { ...meta };
|
const metaCopy = { ...meta };
|
||||||
metaCopy.episode = nextEp;
|
metaCopy.episode = nextEp;
|
||||||
|
setShouldStartFromBeginning(true);
|
||||||
setDirectMeta(metaCopy);
|
setDirectMeta(metaCopy);
|
||||||
props.onChange?.(metaCopy);
|
props.onChange?.(metaCopy);
|
||||||
}, [setDirectMeta, nextEp, meta, props]);
|
}, [setDirectMeta, nextEp, meta, props, setShouldStartFromBeginning]);
|
||||||
|
|
||||||
if (!meta?.episode || !nextEp) return null;
|
if (!meta?.episode || !nextEp) return null;
|
||||||
if (metaType !== "show") return null;
|
if (metaType !== "show") return null;
|
||||||
|
@ -35,6 +35,12 @@ export function usePlayer() {
|
|||||||
const setSource = usePlayerStore((s) => s.setSource);
|
const setSource = usePlayerStore((s) => s.setSource);
|
||||||
const setSourceId = usePlayerStore((s) => s.setSourceId);
|
const setSourceId = usePlayerStore((s) => s.setSourceId);
|
||||||
const status = usePlayerStore((s) => s.status);
|
const status = usePlayerStore((s) => s.status);
|
||||||
|
const shouldStartFromBeginning = usePlayerStore(
|
||||||
|
(s) => s.interface.shouldStartFromBeginning
|
||||||
|
);
|
||||||
|
const setShouldStartFromBeginning = usePlayerStore(
|
||||||
|
(s) => s.setShouldStartFromBeginning
|
||||||
|
);
|
||||||
const reset = usePlayerStore((s) => s.reset);
|
const reset = usePlayerStore((s) => s.reset);
|
||||||
const meta = usePlayerStore((s) => s.meta);
|
const meta = usePlayerStore((s) => s.meta);
|
||||||
const { init } = useInitializePlayer();
|
const { init } = useInitializePlayer();
|
||||||
@ -44,6 +50,8 @@ export function usePlayer() {
|
|||||||
meta,
|
meta,
|
||||||
reset,
|
reset,
|
||||||
status,
|
status,
|
||||||
|
shouldStartFromBeginning,
|
||||||
|
setShouldStartFromBeginning,
|
||||||
setMeta(m: PlayerMeta, newStatus?: PlayerStatus) {
|
setMeta(m: PlayerMeta, newStatus?: PlayerStatus) {
|
||||||
setMeta(m, newStatus);
|
setMeta(m, newStatus);
|
||||||
},
|
},
|
||||||
|
@ -29,7 +29,14 @@ export function PlayerView() {
|
|||||||
sourceOrder: ScrapingItems[];
|
sourceOrder: ScrapingItems[];
|
||||||
} | null>(null);
|
} | null>(null);
|
||||||
const [startAtParam] = useQueryParam("t");
|
const [startAtParam] = useQueryParam("t");
|
||||||
const { status, playMedia, reset, setScrapeNotFound } = usePlayer();
|
const {
|
||||||
|
status,
|
||||||
|
playMedia,
|
||||||
|
reset,
|
||||||
|
setScrapeNotFound,
|
||||||
|
shouldStartFromBeginning,
|
||||||
|
setShouldStartFromBeginning,
|
||||||
|
} = usePlayer();
|
||||||
const { setPlayerMeta, scrapeMedia } = usePlayerMeta();
|
const { setPlayerMeta, scrapeMedia } = usePlayerMeta();
|
||||||
const backUrl = useLastNonPlayerLink();
|
const backUrl = useLastNonPlayerLink();
|
||||||
const { disable } = useCaptions();
|
const { disable } = useCaptions();
|
||||||
@ -61,9 +68,19 @@ export function PlayerView() {
|
|||||||
let startAt: number | undefined;
|
let startAt: number | undefined;
|
||||||
if (startAtParam) startAt = parseTimestamp(startAtParam) ?? undefined;
|
if (startAtParam) startAt = parseTimestamp(startAtParam) ?? undefined;
|
||||||
|
|
||||||
playMedia(convertRunoutputToSource(out), out.sourceId, startAt);
|
playMedia(
|
||||||
|
convertRunoutputToSource(out),
|
||||||
|
out.sourceId,
|
||||||
|
shouldStartFromBeginning ? 0 : startAt
|
||||||
|
);
|
||||||
|
setShouldStartFromBeginning(false);
|
||||||
},
|
},
|
||||||
[playMedia, startAtParam]
|
[
|
||||||
|
playMedia,
|
||||||
|
startAtParam,
|
||||||
|
shouldStartFromBeginning,
|
||||||
|
setShouldStartFromBeginning,
|
||||||
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
useEffectOnce(() => {
|
useEffectOnce(() => {
|
||||||
|
@ -22,6 +22,7 @@ export interface InterfaceSlice {
|
|||||||
canAirplay: boolean;
|
canAirplay: boolean;
|
||||||
isCasting: boolean;
|
isCasting: boolean;
|
||||||
hideNextEpisodeBtn: boolean;
|
hideNextEpisodeBtn: boolean;
|
||||||
|
shouldStartFromBeginning: boolean;
|
||||||
|
|
||||||
volumeChangedWithKeybind: boolean; // has the volume recently been adjusted with the up/down arrows recently?
|
volumeChangedWithKeybind: boolean; // has the volume recently been adjusted with the up/down arrows recently?
|
||||||
volumeChangedWithKeybindDebounce: NodeJS.Timeout | null; // debounce for the duration of the "volume changed thingamajig"
|
volumeChangedWithKeybindDebounce: NodeJS.Timeout | null; // debounce for the duration of the "volume changed thingamajig"
|
||||||
@ -38,6 +39,7 @@ export interface InterfaceSlice {
|
|||||||
setHasOpenOverlay(state: boolean): void;
|
setHasOpenOverlay(state: boolean): void;
|
||||||
setLastVolume(state: number): void;
|
setLastVolume(state: number): void;
|
||||||
hideNextEpisodeButton(): void;
|
hideNextEpisodeButton(): void;
|
||||||
|
setShouldStartFromBeginning(val: boolean): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const createInterfaceSlice: MakeSlice<InterfaceSlice> = (set, get) => ({
|
export const createInterfaceSlice: MakeSlice<InterfaceSlice> = (set, get) => ({
|
||||||
@ -56,8 +58,14 @@ export const createInterfaceSlice: MakeSlice<InterfaceSlice> = (set, get) => ({
|
|||||||
timeFormat: VideoPlayerTimeFormat.REGULAR,
|
timeFormat: VideoPlayerTimeFormat.REGULAR,
|
||||||
canAirplay: false,
|
canAirplay: false,
|
||||||
hideNextEpisodeBtn: false,
|
hideNextEpisodeBtn: false,
|
||||||
|
shouldStartFromBeginning: false,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
setShouldStartFromBeginning(val) {
|
||||||
|
set((s) => {
|
||||||
|
s.interface.shouldStartFromBeginning = val;
|
||||||
|
});
|
||||||
|
},
|
||||||
setLastVolume(state) {
|
setLastVolume(state) {
|
||||||
set((s) => {
|
set((s) => {
|
||||||
s.interface.lastVolume = state;
|
s.interface.lastVolume = state;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user