1
0
Fork 0
mirror of https://github.com/sussy-code/smov.git synced 2024-12-27 15:47:41 +01:00
smov/src/components/media/VideoPlayer.tsx

27 lines
672 B
TypeScript
Raw Normal View History

2022-02-20 16:55:30 +01:00
import { MWMediaStream } from "providers";
import { useRef } from "react";
export interface VideoPlayerProps {
source: MWMediaStream;
onProgress?: (event: ProgressEvent) => void;
}
export function VideoPlayer(props: VideoPlayerProps) {
const videoRef = useRef<HTMLVideoElement | null>(null);
const mustUseHls = props.source.type === "m3u8";
return (
<video
className="videoElement"
ref={videoRef}
onProgress={(e) =>
props.onProgress && props.onProgress(e.nativeEvent as ProgressEvent)
}
controls
autoPlay
>
{!mustUseHls ? <source src={props.source.url} type="video/mp4" /> : null}
</video>
);
}