mirror of
https://github.com/movie-web/movie-web.git
synced 2024-12-28 18:11:50 +01:00
add progress to window
Co-authored-by: Jip Frijlink <JipFr@users.noreply.github.com>
This commit is contained in:
parent
b36324d58e
commit
5fc8355e8e
@ -2,6 +2,7 @@ import { MWCaption } from "@/backend/helpers/streams";
|
|||||||
import { DetailedMeta } from "@/backend/metadata/getmeta";
|
import { DetailedMeta } from "@/backend/metadata/getmeta";
|
||||||
import { useVideoPlayerDescriptor } from "@/video/state/hooks";
|
import { useVideoPlayerDescriptor } from "@/video/state/hooks";
|
||||||
import { useMeta } from "@/video/state/logic/meta";
|
import { useMeta } from "@/video/state/logic/meta";
|
||||||
|
import { useProgress } from "@/video/state/logic/progress";
|
||||||
import { useEffect } from "react";
|
import { useEffect } from "react";
|
||||||
|
|
||||||
export type WindowMeta = {
|
export type WindowMeta = {
|
||||||
@ -17,6 +18,10 @@ export type WindowMeta = {
|
|||||||
title: string;
|
title: string;
|
||||||
episodes?: { id: string; number: number; title: string }[];
|
episodes?: { id: string; number: number; title: string }[];
|
||||||
}[];
|
}[];
|
||||||
|
progress: {
|
||||||
|
time: number;
|
||||||
|
duration: number;
|
||||||
|
};
|
||||||
} | null;
|
} | null;
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
@ -28,6 +33,7 @@ declare global {
|
|||||||
export function MetaAction() {
|
export function MetaAction() {
|
||||||
const descriptor = useVideoPlayerDescriptor();
|
const descriptor = useVideoPlayerDescriptor();
|
||||||
const meta = useMeta(descriptor);
|
const meta = useMeta(descriptor);
|
||||||
|
const progress = useProgress(descriptor);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!window.meta) window.meta = {};
|
if (!window.meta) window.meta = {};
|
||||||
@ -37,13 +43,17 @@ export function MetaAction() {
|
|||||||
captions: meta.captions,
|
captions: meta.captions,
|
||||||
seasons: meta.seasons,
|
seasons: meta.seasons,
|
||||||
episode: meta.episode,
|
episode: meta.episode,
|
||||||
|
progress: {
|
||||||
|
time: progress.time,
|
||||||
|
duration: progress.duration,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
if (window.meta) delete window.meta[descriptor];
|
if (window.meta) delete window.meta[descriptor];
|
||||||
};
|
};
|
||||||
}, [meta, descriptor]);
|
}, [meta, descriptor, progress]);
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user