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

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

Loading…
Cancel
Save