mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-05-30 19:54:16 -04:00
Fix start time reset issue on android by a new t props
This commit is contained in:
parent
08d2bb2fd5
commit
8c910fa532
@ -53,4 +53,4 @@ export const useLocalSetting = (setting: string, def: string) => {
|
|||||||
export const getLocalSetting = (setting: string, def: string) => {
|
export const getLocalSetting = (setting: string, def: string) => {
|
||||||
if (Platform.OS === "web" && typeof window === "undefined") return def;
|
if (Platform.OS === "web" && typeof window === "undefined") return def;
|
||||||
return storage.getString(`settings.${setting}`) ?? setting;
|
return storage.getString(`settings.${setting}`) ?? setting;
|
||||||
}
|
};
|
||||||
|
@ -68,7 +68,15 @@ const mapData = (
|
|||||||
|
|
||||||
let firstSlug: string | null = null;
|
let firstSlug: string | null = null;
|
||||||
|
|
||||||
export const Player = ({ slug, type }: { slug: string; type: "episode" | "movie" }) => {
|
export const Player = ({
|
||||||
|
slug,
|
||||||
|
type,
|
||||||
|
t: startTimeP,
|
||||||
|
}: {
|
||||||
|
slug: string;
|
||||||
|
type: "episode" | "movie";
|
||||||
|
t?: number;
|
||||||
|
}) => {
|
||||||
const { css } = useYoshiki();
|
const { css } = useYoshiki();
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
@ -78,25 +86,16 @@ export const Player = ({ slug, type }: { slug: string; type: "episode" | "movie"
|
|||||||
const { data: info, error: infoError } = useFetch(Player.infoQuery(type, slug));
|
const { data: info, error: infoError } = useFetch(Player.infoQuery(type, slug));
|
||||||
const previous =
|
const previous =
|
||||||
data && data.type === "episode" && data.previousEpisode
|
data && data.type === "episode" && data.previousEpisode
|
||||||
? `/watch/${data.previousEpisode.slug}`
|
? `/watch/${data.previousEpisode.slug}?t=0`
|
||||||
: undefined;
|
: undefined;
|
||||||
const next =
|
const next =
|
||||||
data && data.type === "episode" && data.nextEpisode
|
data && data.type === "episode" && data.nextEpisode
|
||||||
? `/watch/${data.nextEpisode.slug}`
|
? `/watch/${data.nextEpisode.slug}?t=0`
|
||||||
: undefined;
|
: undefined;
|
||||||
|
|
||||||
useVideoKeyboard(info?.subtitles, info?.fonts, previous, next);
|
useVideoKeyboard(info?.subtitles, info?.fonts, previous, next);
|
||||||
|
|
||||||
firstSlug ??= slug;
|
const startTime = startTimeP ?? data?.watchStatus?.watchedTime;
|
||||||
// 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(() => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user