feat: connect YMB APIs and add swipe video player
This commit is contained in:
1 parent
eb3eb8dfc6
commit
6ba0ce1179
19 files changed
+113
-11
No files matched your search
@@ -0,0 +1,8 @@
|
||||
// Author: fruit.com.cn
|
||||
import { useEffect, useRef } from 'react';
|
||||
|
||||
export function VideoPlayer({ src, poster, autoPlay = true, muted = true, onProgress }) {
|
||||
const ref = useRef(null);
|
||||
useEffect(() => { const video = ref.current; if (!video || !src) return undefined; const attempt = video.play(); attempt?.catch(() => {}); return () => video.pause(); }, [src]);
|
||||
return <video ref={ref} className="video-player" src={src} poster={poster} controls playsInline autoPlay={autoPlay} muted={muted} onTimeUpdate={(event) => onProgress?.(event.currentTarget.currentTime)} />;
|
||||
}
|
||||
Reference in new issue
Block a user