mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-06-01 04:34:50 -04:00
Disable start time when switching episodes
This commit is contained in:
parent
b323736774
commit
fab2784e16
@ -36,7 +36,7 @@ import { useRouter } from "solito/router";
|
|||||||
import { useSetAtom } from "jotai";
|
import { useSetAtom } from "jotai";
|
||||||
import { useYoshiki } from "yoshiki/native";
|
import { useYoshiki } from "yoshiki/native";
|
||||||
import { Back, Hover, LoadingIndicator } from "./components/hover";
|
import { Back, Hover, LoadingIndicator } from "./components/hover";
|
||||||
import { fullscreenAtom, progressAtom, Video } from "./state";
|
import { fullscreenAtom, Video } from "./state";
|
||||||
import { episodeDisplayNumber } from "../details/episode";
|
import { episodeDisplayNumber } from "../details/episode";
|
||||||
import { useVideoKeyboard } from "./keyboard";
|
import { useVideoKeyboard } from "./keyboard";
|
||||||
import { MediaSessionManager } from "./media-session";
|
import { MediaSessionManager } from "./media-session";
|
||||||
@ -66,6 +66,8 @@ const mapData = (
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let firstSlug: string | null = null;
|
||||||
|
|
||||||
export const Player = ({ slug, type }: { slug: string; type: "episode" | "movie" }) => {
|
export const Player = ({ slug, type }: { slug: string; type: "episode" | "movie" }) => {
|
||||||
const { css } = useYoshiki();
|
const { css } = useYoshiki();
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
@ -85,6 +87,17 @@ export const Player = ({ slug, type }: { slug: string; type: "episode" | "movie"
|
|||||||
|
|
||||||
useVideoKeyboard(info?.subtitles, info?.fonts, previous, next);
|
useVideoKeyboard(info?.subtitles, info?.fonts, previous, next);
|
||||||
|
|
||||||
|
firstSlug ??= slug;
|
||||||
|
// can't use useRef since the player get's remonted everytime (don't know why)
|
||||||
|
useEffect(() => {
|
||||||
|
return () => {
|
||||||
|
if (!document.location.href.includes("/watch")) firstSlug = null;
|
||||||
|
};
|
||||||
|
}, [slug]);
|
||||||
|
// only use the start time when the player was inited with this episode/movie
|
||||||
|
// (don't actually resume an episode when you auto-play the next for example)
|
||||||
|
const startTime = firstSlug === slug ? data?.watchStatus?.watchedTime : 0;
|
||||||
|
|
||||||
const setFullscreen = useSetAtom(fullscreenAtom);
|
const setFullscreen = useSetAtom(fullscreenAtom);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (Platform.OS !== "web") return;
|
if (Platform.OS !== "web") return;
|
||||||
@ -142,7 +155,7 @@ export const Player = ({ slug, type }: { slug: string; type: "episode" | "movie"
|
|||||||
subtitles={info?.subtitles}
|
subtitles={info?.subtitles}
|
||||||
setError={setPlaybackError}
|
setError={setPlaybackError}
|
||||||
fonts={info?.fonts}
|
fonts={info?.fonts}
|
||||||
startTime={data?.watchStatus?.watchedTime}
|
startTime={startTime}
|
||||||
onEnd={() => {
|
onEnd={() => {
|
||||||
if (!data) return;
|
if (!data) return;
|
||||||
if (data.type === "movie")
|
if (data.type === "movie")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user