rht
This commit is contained in:
parent
888ea28168
commit
c4671ffdfe
|
@ -25,6 +25,7 @@ export const VideoDisplay: React.FC<VideoDisplayProps> = ({
|
||||||
isDragging,
|
isDragging,
|
||||||
setIsDragging,
|
setIsDragging,
|
||||||
progressRef,
|
progressRef,
|
||||||
|
isPlaying
|
||||||
} = useContext(VideoPlayerContext);
|
} = useContext(VideoPlayerContext);
|
||||||
|
|
||||||
// 处理进度条拖拽
|
// 处理进度条拖拽
|
||||||
|
@ -192,15 +193,19 @@ export const VideoDisplay: React.FC<VideoDisplayProps> = ({
|
||||||
}, [src, onError, autoPlay]);
|
}, [src, onError, autoPlay]);
|
||||||
|
|
||||||
const handleVideoClick = () => {
|
const handleVideoClick = () => {
|
||||||
if (videoRef.current) {
|
if (videoRef.current && isPlaying) {
|
||||||
videoRef.current.pause();
|
videoRef.current.pause();
|
||||||
setIsPlaying(false);
|
setIsPlaying(false);
|
||||||
|
}else if (videoRef.current && !isPlaying) {
|
||||||
|
videoRef.current.play();
|
||||||
|
setIsPlaying(true);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="relative w-full aspect-video" onClick={handleVideoClick}>
|
<div className="relative w-full aspect-video" >
|
||||||
<video
|
<video
|
||||||
|
onClick={handleVideoClick}
|
||||||
ref={videoRef}
|
ref={videoRef}
|
||||||
className="w-full h-full"
|
className="w-full h-full"
|
||||||
poster={poster}
|
poster={poster}
|
||||||
|
|
Loading…
Reference in New Issue