diff --git a/src/components/Video/AliPlayer.d.ts b/src/components/Video/AliPlayer.d.ts index 575243d..efb73dd 100644 --- a/src/components/Video/AliPlayer.d.ts +++ b/src/components/Video/AliPlayer.d.ts @@ -25,6 +25,8 @@ export interface AliPlayerProps { onEnded?: () => void; /** 播放进度更新事件 */ onTimeupdate?: (currentTime: number) => void; + /** 获取播放器实例 */ + onGetPlayerInstance?: (player: any) => void; /** 传递给 AliPlayer 的属性 */ aliPlayerProps?: Record; } diff --git a/src/components/Video/AliPlayer.js b/src/components/Video/AliPlayer.js index 38c423a..7f1b7c7 100644 --- a/src/components/Video/AliPlayer.js +++ b/src/components/Video/AliPlayer.js @@ -19,6 +19,7 @@ const AliPlayer = forwardRef(({ playTime = 0, onEnded, onTimeupdate, + onGetPlayerInstance, aliPlayerProps, }, ref) => { const playerRef = useRef(null); @@ -125,6 +126,7 @@ const AliPlayer = forwardRef(({ ...aliPlayerProps, }, (player) => { + onGetPlayerInstance && onGetPlayerInstance(player); if (autoplay) { player.play(); } diff --git a/src/components/Video/index.js b/src/components/Video/index.js index 7e4017e..11f22cb 100644 --- a/src/components/Video/index.js +++ b/src/components/Video/index.js @@ -23,6 +23,7 @@ const Video = forwardRef(({ onCancel, onEnded, onTimeupdate, + onGetPlayerInstance, aliPlayerProps = {}, }, ref) => { const [internalVisible, setInternalVisible] = useState(false); @@ -76,6 +77,7 @@ const Video = forwardRef(({ aliPlayerProps={aliPlayerProps} onEnded={onEnded} onTimeupdate={onTimeupdate} + onGetPlayerInstance={onGetPlayerInstance} /> );