diff --git a/src/element/live-video-player.tsx b/src/element/live-video-player.tsx index bb1cc9e..378205f 100644 --- a/src/element/live-video-player.tsx +++ b/src/element/live-video-player.tsx @@ -1,5 +1,5 @@ import { useMemo, useState } from "react"; -import ReactPlayer from 'react-player/lazy' +import ReactPlayer from 'react-player' export enum VideoStatus { Online = "online", @@ -14,44 +14,7 @@ export interface VideoPlayerProps { export function LiveVideoPlayer(props: VideoPlayerProps) { const streamCached = useMemo(() => props.stream, [props.stream]); - const [status, setStatus] = useState(); - // const [src, setSrc] = useState(); - - // useEffect(() => { - // if (streamCached && video.current) { - // if (Hls.isSupported()) { - // try { - // const hls = new Hls(); - // hls.loadSource(streamCached); - // hls.attachMedia(video.current); - // hls.on(Hls.Events.ERROR, (event, data) => { - // console.debug(event, data); - // const errorType = data.type; - // if (errorType === Hls.ErrorTypes.NETWORK_ERROR && data.fatal) { - // hls.stopLoad(); - // hls.detachMedia(); - // setStatus(VideoStatus.Offline); - // } - // }); - // hls.on(Hls.Events.MANIFEST_PARSED, () => { - // setStatus(VideoStatus.Online); - // }); - // hls.on(Hls.Events.LEVEL_SWITCHING, (e, l) => { - // console.debug("HLS Level Switch", l); - // }); - // return () => hls.destroy(); - // } catch (e) { - // console.error(e); - // setStatus(VideoStatus.Offline); - // } - // } else { - // setSrc(streamCached); - // setStatus(VideoStatus.Online); - // video.current.muted = true; - // video.current.load(); - // } - // } - // }, [video, streamCached, props.status]); + const [status, setStatus] = useState(VideoStatus.Online); return (
@@ -67,13 +30,17 @@ export function LiveVideoPlayer(props: VideoPlayerProps) { height='100%' controls={true} playsinline={true} - light={Thumbnail} - onProgress={(...args)=>{ - console.log('onProgress:args',args) + light={Thumbnail} + onProgress={()=>{ setStatus(VideoStatus.Online); }} - onError={(...args)=>{ - console.log('onError:args',args) + onError={()=>{ setStatus(VideoStatus.Offline); }} />