This commit is contained in:
Rao 2025-03-05 17:30:25 +08:00
parent 888ea28168
commit c4671ffdfe
1 changed files with 7 additions and 2 deletions

View File

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