diff --git a/src/packages/video/demo.tsx b/src/packages/video/demo.tsx index f0efafb01e..7683c6d533 100644 --- a/src/packages/video/demo.tsx +++ b/src/packages/video/demo.tsx @@ -13,7 +13,7 @@ const VideoDemo = () => { const [translated] = useTranslate({ 'zh-CN': { basic: '基础用法', - autoPlay: '自动播放', + autoPlay: '自动播放,支持 Ref 暂停 和继续播放', muted: '初始化静音', cover: '视频封面海报设置', inline: '行内播放', @@ -22,7 +22,7 @@ const VideoDemo = () => { }, 'zh-TW': { basic: '基礎用法', - autoPlay: '自動播放', + autoPlay: '自動播放,支持 Ref 暫停 和繼續播放', muted: '初始化靜音', cover: '視頻封面海報設置', inline: '行內播放', @@ -31,7 +31,7 @@ const VideoDemo = () => { }, 'en-US': { basic: 'Basic Usage', - autoPlay: 'Auto play', + autoPlay: 'Auto play, Ref pause and play', muted: 'Initialize mute', cover: 'Video cover poster settings', inline: 'play inline', diff --git a/src/packages/video/demos/h5/demo2.tsx b/src/packages/video/demos/h5/demo2.tsx index b819a18bd6..7b8be0423f 100644 --- a/src/packages/video/demos/h5/demo2.tsx +++ b/src/packages/video/demos/h5/demo2.tsx @@ -1,4 +1,4 @@ -import React, { useState } from 'react' +import React, { useState, useRef } from 'react' import { Cell, Video } from '@nutui/nutui-react' const Demo2 = () => { @@ -14,10 +14,21 @@ const Demo2 = () => { const play = (elm: HTMLVideoElement) => console.log('play', elm) const pause = (elm: HTMLVideoElement) => console.log('pause', elm) const playend = (elm: HTMLVideoElement) => console.log('playend', elm) + + const rootRef = useRef(null) + setTimeout(() => { + rootRef?.current?.pause() + }, 2000) + + setTimeout(() => { + rootRef?.current?.play() + }, 4000) + return ( <>