import { useEffect, useMemo } from "react"; import { MWStreamType } from "@/backend/helpers/streams"; import { BrandPill } from "@/components/layout/BrandPill"; import { Player } from "@/components/player"; import { AutoPlayStart } from "@/components/player/atoms"; import { usePlayer } from "@/components/player/hooks/usePlayer"; import { useShouldShowControls } from "@/components/player/hooks/useShouldShowControls"; import { ScrapingPart } from "@/pages/parts/player/ScrapingPart"; import { PlayerMeta, metaToScrapeMedia, playerStatus, } from "@/stores/player/slices/source"; export function PlayerView() { const { status, setScrapeStatus, playMedia, setMeta } = usePlayer(); const { showTargets, showTouchTargets } = useShouldShowControls(); const meta = useMemo( () => ({ type: "show", title: "Normal People", releaseYear: 2020, tmdbId: "89905", episode: { number: 12, tmdbId: "2207576", title: "Episode 12" }, season: { number: 1, tmdbId: "125160", title: "Season 1" }, }), [] ); useEffect(() => { setMeta(meta); }, [setMeta, meta]); const scrapeMedia = useMemo(() => metaToScrapeMedia(meta), [meta]); return ( {status === playerStatus.SCRAPING ? ( { if (out?.stream.type !== "file") return; console.log(out.stream.qualities); const qualities = Object.keys(out.stream.qualities).sort( (a, b) => Number(b) - Number(a) ) as (keyof typeof out.stream.qualities)[]; let file; for (const quality of qualities) { if (out.stream.qualities[quality]?.url) { console.log(quality); file = out.stream.qualities[quality]; break; } } if (!file) return; playMedia({ type: MWStreamType.MP4, url: file.url, }); }} /> ) : null}
/
{/* Do mobile controls here :) */}
); }