H5 去掉controls ,实现点击视频播放/暂停

This commit is contained in:
北枳 2025-10-06 17:53:06 +08:00
parent 444e8bc58e
commit 991b5a8682

View File

@ -218,17 +218,20 @@ export function H5MediaViewer({
<> <>
<video <video
ref={(el) => (videoRefs.current[idx] = el)} ref={(el) => (videoRefs.current[idx] = el)}
className="w-full h-full object-contain [transform:translateZ(0)] [backface-visibility:hidden] [will-change:transform] bg-black" className="w-full h-full object-contain [transform:translateZ(0)] [backface-visibility:hidden] [will-change:transform] bg-black cursor-pointer"
style={{ style={{
maxHeight: '100%', maxHeight: '100%',
}} }}
src={url} src={url}
preload="metadata" preload="metadata"
playsInline playsInline
controls={isPlaying && activeIndex === idx}
loop loop
poster={getFirstFrame(url)} poster={getFirstFrame(url)}
crossOrigin="anonymous" crossOrigin="anonymous"
onClick={(e) => {
e.stopPropagation();
if (activeIndex === idx) togglePlay();
}}
onLoadedMetadata={() => {}} onLoadedMetadata={() => {}}
onPlay={() => { onPlay={() => {
if (activeIndex === idx) setIsPlaying(true); if (activeIndex === idx) setIsPlaying(true);