2023-10-05 22:12:25 +02:00
|
|
|
import { MWStreamType } from "@/backend/helpers/streams";
|
2023-10-02 21:04:40 +02:00
|
|
|
import { BrandPill } from "@/components/layout/BrandPill";
|
2023-07-23 15:00:08 +02:00
|
|
|
import { Player } from "@/components/player";
|
2023-10-05 22:12:25 +02:00
|
|
|
import { AutoPlayStart } from "@/components/player/atoms";
|
2023-09-30 20:57:00 +02:00
|
|
|
import { usePlayer } from "@/components/player/hooks/usePlayer";
|
2023-10-02 21:04:40 +02:00
|
|
|
import { useShouldShowControls } from "@/components/player/hooks/useShouldShowControls";
|
2023-10-01 21:08:26 +02:00
|
|
|
import { ScrapingPart } from "@/pages/parts/player/ScrapingPart";
|
2023-09-30 20:57:00 +02:00
|
|
|
import { playerStatus } from "@/stores/player/slices/source";
|
2023-07-23 15:00:08 +02:00
|
|
|
|
|
|
|
export function PlayerView() {
|
2023-10-05 22:12:25 +02:00
|
|
|
const { status, setScrapeStatus, playMedia } = usePlayer();
|
2023-10-02 21:04:40 +02:00
|
|
|
const desktopControlsVisible = useShouldShowControls();
|
2023-10-01 17:34:37 +02:00
|
|
|
|
2023-07-23 15:00:08 +02:00
|
|
|
return (
|
2023-10-01 17:34:37 +02:00
|
|
|
<Player.Container onLoad={setScrapeStatus}>
|
2023-10-02 21:04:40 +02:00
|
|
|
{status === playerStatus.SCRAPING ? (
|
|
|
|
<ScrapingPart
|
|
|
|
media={{
|
|
|
|
type: "movie",
|
2023-10-06 00:20:53 +02:00
|
|
|
title: "Everything Everywhere All At Once",
|
2023-10-02 21:04:40 +02:00
|
|
|
tmdbId: "545611",
|
|
|
|
releaseYear: 2022,
|
|
|
|
}}
|
2023-10-05 22:12:25 +02:00
|
|
|
onGetStream={(out) => {
|
|
|
|
if (out?.stream.type !== "file") return;
|
|
|
|
const qualities = Object.keys(
|
|
|
|
out.stream.qualities
|
|
|
|
) as (keyof typeof out.stream.qualities)[];
|
|
|
|
const file = out.stream.qualities[qualities[0]];
|
|
|
|
if (!file) return;
|
|
|
|
playMedia({
|
|
|
|
type: MWStreamType.MP4,
|
|
|
|
url: file.url,
|
|
|
|
});
|
|
|
|
}}
|
2023-10-02 21:04:40 +02:00
|
|
|
/>
|
|
|
|
) : null}
|
|
|
|
|
|
|
|
<Player.BlackOverlay show={desktopControlsVisible} />
|
2023-10-05 22:12:25 +02:00
|
|
|
|
|
|
|
<Player.CenterControls>
|
|
|
|
<Player.LoadingSpinner />
|
|
|
|
<AutoPlayStart />
|
|
|
|
</Player.CenterControls>
|
|
|
|
|
2023-10-02 21:04:40 +02:00
|
|
|
<Player.TopControls show={desktopControlsVisible}>
|
|
|
|
<div className="grid grid-cols-[1fr,auto] xl:grid-cols-3 items-center">
|
|
|
|
<div className="flex space-x-3 items-center">
|
|
|
|
<Player.BackLink />
|
|
|
|
<Player.BookmarkButton />
|
|
|
|
</div>
|
|
|
|
<div className="text-center hidden xl:flex justify-center items-center">
|
|
|
|
<span className="text-white font-medium mr-3">S1 E5</span>
|
|
|
|
<span className="text-type-secondary font-medium">
|
|
|
|
Mr. Jeebaloo discovers Atlantis
|
|
|
|
</span>
|
|
|
|
</div>
|
|
|
|
<div className="flex items-center justify-end">
|
|
|
|
<BrandPill />
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</Player.TopControls>
|
2023-10-05 22:12:25 +02:00
|
|
|
|
2023-10-02 21:04:40 +02:00
|
|
|
<Player.BottomControls show={desktopControlsVisible}>
|
2023-10-01 21:08:26 +02:00
|
|
|
<Player.ProgressBar />
|
|
|
|
<div className="flex justify-between">
|
2023-10-08 17:48:48 +02:00
|
|
|
<Player.LeftSideControls>
|
2023-10-01 21:08:26 +02:00
|
|
|
<Player.Pause />
|
|
|
|
<Player.SkipBackward />
|
|
|
|
<Player.SkipForward />
|
2023-10-08 17:48:48 +02:00
|
|
|
<Player.Volume />
|
2023-10-01 21:08:26 +02:00
|
|
|
<Player.Time />
|
2023-10-08 17:48:48 +02:00
|
|
|
</Player.LeftSideControls>
|
2023-10-01 21:08:26 +02:00
|
|
|
<div>
|
|
|
|
<Player.Fullscreen />
|
|
|
|
</div>
|
|
|
|
</div>
|
2023-10-01 17:34:37 +02:00
|
|
|
</Player.BottomControls>
|
2023-07-23 15:00:08 +02:00
|
|
|
</Player.Container>
|
|
|
|
);
|
|
|
|
}
|