mirror of
https://github.com/movie-web/movie-web.git
synced 2024-11-13 10:55:04 +01:00
Add premid support back (in different format)
This commit is contained in:
parent
340673237b
commit
9c1195e131
@ -4,6 +4,7 @@ import { OverlayDisplay } from "@/components/overlays/OverlayDisplay";
|
|||||||
import { CastingInternal } from "@/components/player/internals/CastingInternal";
|
import { CastingInternal } from "@/components/player/internals/CastingInternal";
|
||||||
import { HeadUpdater } from "@/components/player/internals/HeadUpdater";
|
import { HeadUpdater } from "@/components/player/internals/HeadUpdater";
|
||||||
import { KeyboardEvents } from "@/components/player/internals/KeyboardEvents";
|
import { KeyboardEvents } from "@/components/player/internals/KeyboardEvents";
|
||||||
|
import { MetaReporter } from "@/components/player/internals/MetaReporter";
|
||||||
import { ProgressSaver } from "@/components/player/internals/ProgressSaver";
|
import { ProgressSaver } from "@/components/player/internals/ProgressSaver";
|
||||||
import { ThumbnailScraper } from "@/components/player/internals/ThumbnailScraper";
|
import { ThumbnailScraper } from "@/components/player/internals/ThumbnailScraper";
|
||||||
import { VideoClickTarget } from "@/components/player/internals/VideoClickTarget";
|
import { VideoClickTarget } from "@/components/player/internals/VideoClickTarget";
|
||||||
@ -84,6 +85,7 @@ export function Container(props: PlayerProps) {
|
|||||||
return (
|
return (
|
||||||
<div className="relative">
|
<div className="relative">
|
||||||
<BaseContainer>
|
<BaseContainer>
|
||||||
|
<MetaReporter />
|
||||||
<ThumbnailScraper />
|
<ThumbnailScraper />
|
||||||
<CastingInternal />
|
<CastingInternal />
|
||||||
<VideoContainer />
|
<VideoContainer />
|
||||||
|
88
src/components/player/internals/MetaReporter.tsx
Normal file
88
src/components/player/internals/MetaReporter.tsx
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
import { useEffect } from "react";
|
||||||
|
|
||||||
|
import { usePlayerStore } from "@/stores/player/store";
|
||||||
|
|
||||||
|
export type WindowMeta = {
|
||||||
|
meta: {
|
||||||
|
type: "show" | "movie";
|
||||||
|
tmdbId: string;
|
||||||
|
title: string;
|
||||||
|
year: number;
|
||||||
|
poster?: string;
|
||||||
|
};
|
||||||
|
episode?: {
|
||||||
|
number: number;
|
||||||
|
tmdbId: string;
|
||||||
|
title: string;
|
||||||
|
};
|
||||||
|
season?: {
|
||||||
|
number: number;
|
||||||
|
tmdbId: string;
|
||||||
|
title: string;
|
||||||
|
};
|
||||||
|
progress: {
|
||||||
|
time: number;
|
||||||
|
duration: number;
|
||||||
|
};
|
||||||
|
controls: {
|
||||||
|
isPlaying: boolean;
|
||||||
|
isLoading: boolean;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
declare global {
|
||||||
|
interface Window {
|
||||||
|
meta?: {
|
||||||
|
player?: WindowMeta;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function MetaReporter() {
|
||||||
|
const meta = usePlayerStore((s) => s.meta);
|
||||||
|
const progress = usePlayerStore((s) => s.progress);
|
||||||
|
const mediaPlaying = usePlayerStore((s) => s.mediaPlaying);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!window.meta) window.meta = {};
|
||||||
|
if (meta) {
|
||||||
|
window.meta.player = {
|
||||||
|
meta: {
|
||||||
|
title: meta.title,
|
||||||
|
type: meta.type,
|
||||||
|
tmdbId: meta.tmdbId,
|
||||||
|
year: meta.releaseYear,
|
||||||
|
poster: meta.poster,
|
||||||
|
},
|
||||||
|
controls: {
|
||||||
|
isPlaying: mediaPlaying.isPlaying,
|
||||||
|
isLoading: mediaPlaying.isLoading,
|
||||||
|
},
|
||||||
|
season: meta.season
|
||||||
|
? {
|
||||||
|
number: meta.season.number,
|
||||||
|
tmdbId: meta.season.tmdbId,
|
||||||
|
title: meta.season.title,
|
||||||
|
}
|
||||||
|
: undefined,
|
||||||
|
episode: meta.episode
|
||||||
|
? {
|
||||||
|
number: meta.episode.number,
|
||||||
|
tmdbId: meta.episode.tmdbId,
|
||||||
|
title: meta.episode.title,
|
||||||
|
}
|
||||||
|
: undefined,
|
||||||
|
progress: {
|
||||||
|
time: progress.time,
|
||||||
|
duration: progress.duration,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
if (window.meta) delete window.meta.player;
|
||||||
|
};
|
||||||
|
}, [meta, progress, mediaPlaying]);
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user