uniapp 视频默认全屏播放

2,290 阅读1分钟

uniapp 视频默认全屏播放

参考链接blog.csdn.net/qq_38998250…

uniapp 文档上也有介绍createVideoContext

重要的事情说三遍 this this this,记得createVideoContext第一个参数为video的ID,第二个参数组件实例this
onReady: function(){
  this.videoContext = uni.createVideoContext('myVideo', this);
  this.videoContext.requestFullScreen();
}
<video id="myVideo" :src="videoUrl" @fullscreenchange="fullscreenchange"></video>
退出全屏时,停止播放
fullscreenchange (e){
  if(!e.detail.fullScreen){
    this.videoContext.stop()
  }
}