|
|
@ -191,7 +191,7 @@ export const VideoPlayer = React.forwardRef<refType, VideoPlayerProps>( |
|
|
|
if (autoPlay && identifier) { |
|
|
|
if (autoPlay && identifier) { |
|
|
|
setStartPlay(true); |
|
|
|
setStartPlay(true); |
|
|
|
setPlaying(true); |
|
|
|
setPlaying(true); |
|
|
|
togglePlay(undefined, true); |
|
|
|
togglePlay(true); |
|
|
|
} |
|
|
|
} |
|
|
|
}, [autoPlay, startPlay, identifier]); |
|
|
|
}, [autoPlay, startPlay, identifier]); |
|
|
|
|
|
|
|
|
|
|
@ -216,7 +216,7 @@ export const VideoPlayer = React.forwardRef<refType, VideoPlayerProps>( |
|
|
|
const toggleRef = useRef<any>(null); |
|
|
|
const toggleRef = useRef<any>(null); |
|
|
|
const { downloadVideo } = useContext(MyContext); |
|
|
|
const { downloadVideo } = useContext(MyContext); |
|
|
|
|
|
|
|
|
|
|
|
const togglePlay = async (event?: any, isPlay?: boolean) => { |
|
|
|
const togglePlay = async (isPlay?: boolean) => { |
|
|
|
if (!videoRef.current) return; |
|
|
|
if (!videoRef.current) return; |
|
|
|
|
|
|
|
|
|
|
|
setStartPlay(true); |
|
|
|
setStartPlay(true); |
|
|
@ -230,16 +230,12 @@ export const VideoPlayer = React.forwardRef<refType, VideoPlayerProps>( |
|
|
|
}); |
|
|
|
}); |
|
|
|
getSrc(); |
|
|
|
getSrc(); |
|
|
|
} |
|
|
|
} |
|
|
|
if (playing && !isPlay) { |
|
|
|
|
|
|
|
videoRef.current.pause(); |
|
|
|
if (isPlay) setPlaying(true); |
|
|
|
} else { |
|
|
|
else setPlaying(prevState => !prevState); |
|
|
|
await videoRef.current.play(); |
|
|
|
|
|
|
|
} |
|
|
|
if (playing && !isPlay) videoRef.current.pause(); |
|
|
|
if (isPlay) { |
|
|
|
else await videoRef.current.play(); |
|
|
|
setPlaying(true); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
setPlaying(!playing); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
const onVolumeChange = (_: any, value: number | number[]) => { |
|
|
|
const onVolumeChange = (_: any, value: number | number[]) => { |
|
|
@ -475,20 +471,15 @@ export const VideoPlayer = React.forwardRef<refType, VideoPlayerProps>( |
|
|
|
videoRef.current.src = src; |
|
|
|
videoRef.current.src = src; |
|
|
|
videoRef.current.load(); |
|
|
|
videoRef.current.load(); |
|
|
|
videoRef.current.currentTime = currentTime; |
|
|
|
videoRef.current.currentTime = currentTime; |
|
|
|
if (playing) { |
|
|
|
if (playing) await videoRef.current.play(); |
|
|
|
await videoRef.current.play(); |
|
|
|
setPlaying(true); |
|
|
|
} |
|
|
|
|
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
const refetchInInterval = () => { |
|
|
|
const refetchInInterval = () => { |
|
|
|
try { |
|
|
|
try { |
|
|
|
const interval = setInterval(() => { |
|
|
|
const interval = setInterval(() => { |
|
|
|
if (status?.current === "DOWNLOADED") { |
|
|
|
if (status?.current === "DOWNLOADED") refetch(); |
|
|
|
refetch(); |
|
|
|
if (status?.current === "READY") clearInterval(interval); |
|
|
|
} |
|
|
|
|
|
|
|
if (status?.current === "READY") { |
|
|
|
|
|
|
|
clearInterval(interval); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}, 7500); |
|
|
|
}, 7500); |
|
|
|
} catch (error) { |
|
|
|
} catch (error) { |
|
|
|
console.log(error); |
|
|
|
console.log(error); |
|
|
@ -830,7 +821,7 @@ export const VideoPlayer = React.forwardRef<refType, VideoPlayerProps>( |
|
|
|
poster={!startPlay ? poster : ""} |
|
|
|
poster={!startPlay ? poster : ""} |
|
|
|
onTimeUpdate={updateProgress} |
|
|
|
onTimeUpdate={updateProgress} |
|
|
|
autoPlay={autoplay} |
|
|
|
autoPlay={autoplay} |
|
|
|
onClick={togglePlay} |
|
|
|
onClick={() => togglePlay()} |
|
|
|
onEnded={handleEnded} |
|
|
|
onEnded={handleEnded} |
|
|
|
// onLoadedMetadata={handleLoadedMetadata}
|
|
|
|
// onLoadedMetadata={handleLoadedMetadata}
|
|
|
|
onCanPlay={handleCanPlay} |
|
|
|
onCanPlay={handleCanPlay} |
|
|
@ -861,7 +852,7 @@ export const VideoPlayer = React.forwardRef<refType, VideoPlayerProps>( |
|
|
|
sx={{ |
|
|
|
sx={{ |
|
|
|
color: "rgba(255, 255, 255, 0.7)", |
|
|
|
color: "rgba(255, 255, 255, 0.7)", |
|
|
|
}} |
|
|
|
}} |
|
|
|
onClick={togglePlay} |
|
|
|
onClick={() => togglePlay()} |
|
|
|
> |
|
|
|
> |
|
|
|
{playing ? <Pause /> : <PlayArrow />} |
|
|
|
{playing ? <Pause /> : <PlayArrow />} |
|
|
|
</IconButton> |
|
|
|
</IconButton> |
|
|
@ -935,7 +926,7 @@ export const VideoPlayer = React.forwardRef<refType, VideoPlayerProps>( |
|
|
|
sx={{ |
|
|
|
sx={{ |
|
|
|
color: "rgba(255, 255, 255, 0.7)", |
|
|
|
color: "rgba(255, 255, 255, 0.7)", |
|
|
|
}} |
|
|
|
}} |
|
|
|
onClick={togglePlay} |
|
|
|
onClick={() => togglePlay()} |
|
|
|
> |
|
|
|
> |
|
|
|
{playing ? <Pause /> : <PlayArrow />} |
|
|
|
{playing ? <Pause /> : <PlayArrow />} |
|
|
|
</IconButton> |
|
|
|
</IconButton> |
|
|
|