From 75b26f6b55393bd3559f40ea3b7b52dedbe7d071 Mon Sep 17 00:00:00 2001 From: LiuJiaNan <15703339975@163.com> Date: Thu, 2 Apr 2026 11:45:28 +0800 Subject: [PATCH] =?UTF-8?q?feat(video):=20=E6=B7=BB=E5=8A=A0=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E6=92=AD=E6=94=BE=E5=99=A8=E5=AE=9E=E4=BE=8B=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在 AliPlayer 组件中新增 onGetPlayerInstance 属性定义 - 将 onGetPlayerInstance 作为参数传递给内部播放器组件 - 实现播放器实例回调功能,支持外部访问播放器对象 - 更新 Video 组件接口以透传播放器实例回调函数 --- src/components/Video/AliPlayer.d.ts | 2 ++ src/components/Video/AliPlayer.js | 2 ++ src/components/Video/index.js | 2 ++ 3 files changed, 6 insertions(+) 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} /> );