movie-web/src/pages/PlayerView.tsx

52 lines
1.6 KiB
TypeScript
Raw Normal View History

import { useCallback } from "react";
2023-09-30 20:57:00 +02:00
import { MWStreamType } from "@/backend/helpers/streams";
import { Player } from "@/components/player";
2023-09-30 20:57:00 +02:00
import { usePlayer } from "@/components/player/hooks/usePlayer";
import { ScrapingPart } from "@/pages/parts/player/ScrapingPart";
2023-09-30 20:57:00 +02:00
import { playerStatus } from "@/stores/player/slices/source";
export function PlayerView() {
const { status, playMedia, setScrapeStatus } = usePlayer();
2023-09-30 20:57:00 +02:00
const startStream = useCallback(() => {
2023-09-30 20:57:00 +02:00
playMedia({
type: MWStreamType.MP4,
// url: "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4",
// url: "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/WhatCarCanYouGetForAGrand.mp4",
url: "http://95.111.247.180/frog.mp4",
2023-09-30 20:57:00 +02:00
});
}, [playMedia]);
return (
<Player.Container onLoad={setScrapeStatus}>
<Player.BottomControls>
<Player.ProgressBar />
<div className="flex justify-between">
<div className="flex space-x-3 items-center">
<Player.Pause />
<Player.SkipBackward />
<Player.SkipForward />
<Player.Time />
</div>
<div>
<Player.Fullscreen />
</div>
</div>
</Player.BottomControls>
2023-09-30 20:57:00 +02:00
{status === playerStatus.SCRAPING ? (
<ScrapingPart
onGetStream={startStream}
media={{
type: "movie",
title: "Hamilton",
tmdbId: "556574",
releaseYear: 2020,
}}
/>
2023-09-30 20:57:00 +02:00
) : null}
</Player.Container>
);
}