解决视频播放不能退出全屏

main
king 1 year ago
parent 66b99de2ba
commit 164511130e
  1. 14
      src/components/video/video.tsx

@ -8,7 +8,6 @@ import videoEvents from "@/hooks/videoEvents";
const deviation: number = 1
const HVideo: FC<HVideoOptions> = (opt: HVideoOptions) => {
let video: Taro.VideoContext
const [currentTime, setCurrentTime] = useState(0)
try {
@ -42,9 +41,13 @@ const HVideo: FC<HVideoOptions> = (opt: HVideoOptions) => {
/** 判断是否进入断点 */
opt.breakpoint.forEach(d => {
if (time < d + deviation && time > d - deviation) {
video.exitFullScreen()
video?.pause()
video?.seek(d - deviation)
if (process.env.TARO_ENV === 'h5') {
document?.exitFullscreen()
}
video?.exitFullScreen()
// if (opt.preview) {
// Taro.showModal({
@ -107,11 +110,14 @@ const HVideo: FC<HVideoOptions> = (opt: HVideoOptions) => {
<Video
id={'myVideo'}
autoplay
enablePlayGesture
autoPauseIfOpenNative
vslideGestureInFullscreen
showCenterPlayBtn
style={{width: '100%', height: '100%', position: "relative"}}
poster={opt?.poster || ''}
src={opt.src}
showRateBtn='swan'
enableProgressGesture={false}
enableProgressGesture={opt.preview}
direction={90}
onTimeUpdate={onTimeUpdate}
onEnded={onEnded}

Loading…
Cancel
Save