video 按钮全屏

微信小程序方法:

<video class="my-video1" id="myVideo1" bindfullscreenchange="screenChange" src="{{ossPath+'video/dunhuang-video202201051033.mp4'}}" controls='controls'></video>
点击进入全屏:

showVideo1() {
    let videoContext = wx.createVideoContext('myVideo1');  //获取video的dom
    videoContext.requestFullScreen({ direction: 90 });
    videoContext.play() //视频播放
},

另一种方法

  <video bindtap="fullscreen" id="myVideo" style="width: 100rpx; height: 100rpx;" src="http://jixiequan-miniapp.oss-cn-beijing.aliyuncs.com/attach/video/2023/08/30/fd618202308301522291090.mp4"/>

//按钮事件
 fullscreen() {
    let videoContext = wx.createVideoContext('myVideo');  //获取video的dom
    videoContext.requestFullScreen({ direction: 90 });
    videoContext.play() //视频播放
  }

监听是否退出或进入全屏:(在video上绑定bindfullscreenchange事件)

screenChange(e) {
    let fullScreen = e.detail.fullScreen //值true为进入全屏,false为退出全屏
    let videoContext = wx.createVideoContext('myVideo1');
},

h5方法:

点击进入全屏:

<video id="product1" controls="false" webview.allowsInlineMediaPlayback=YES; x5-video-player-type="h5" x5-video-player-fullscreen="true" x5-video-orientation="portraint" :src="videoPath+'qhtalent202112/product-info.mp4'">
</video>
//判断进入退出全屏
checkIsFullScreen() {
    var isFullScreen = document.fullscreen || document.mozFullScreen || document.webkitIsFullScreen;
    return isFullScreen == undefined ? false : isFullScreen;
},
// 全屏
Screen(element) {
    if (element.requestFullscreen) {
        element.requestFullscreen();
    } else if (element.mozRequestFullScreen) {
        element.mozRequestFullScreen();
    } else if (element.msRequestFullscreen) {
        element.msRequestFullscreen();
    } else if (element.oRequestFullscreen) {
        element.oRequestFullscreen();
    } else if (element.webkitRequestFullscreen) {
        element.webkitRequestFullScreen();
    } else {
        var requestFullscreen =
            document.documentElement.requestFullscreen ||
            document.documentElement.webkitRequestFullscreen ||
            document.documentElement.mozRequestFullscreen ||
            document.documentElement.requestFullScreen ||
            document.documentElement.webkitRequestFullScreen ||
            document.documentElement.mozRequestFullScreen;
        if (requestFullscreen) {
            requestFullscreen.call(document.documentElement);
        }
        //ios不处理,自动就会全屏
    }
    element.play()
},
//点读笔播放视频
productBtn() {
    let product1 = document.getElementById('product1')
    product1.play()
    this.Screen(product1)
},
document.addEventListener('fullscreenchange', () => {
    if (this.checkIsFullScreen()) {
        this.productPlay = true
        console.log("进入全屏");
    } else {
        console.log("退出全屏");
        this.productPlay = false
        document.getElementById('product1').pause()
    }
});
相关推荐
努力学习的木子2 小时前
uniapp如何隐藏默认的页面头部导航栏,uniapp开发小程序如何隐藏默认的页面头部导航栏
前端·小程序·uni-app
guanpinkeji8 小时前
家政小程序的开发,带动市场快速发展,提高家政服务质量
小程序·小程序开发·家政·家政小程序·家政服务小程序
Cc_Debugger8 小时前
微信小程序消息通知(一次订阅)
微信小程序·小程序
栗豆包14 小时前
【计算机毕业设计】020基于weixin小程序订餐系统
小程序·课程设计
2401_8459364514 小时前
PHP智慧门店微信小程序系统源码
微信·微信小程序·小程序·微信公众平台·微信开放平台
井眼14 小时前
微信小程序-组件样式隔离
微信小程序·小程序
社会底层无业大学生1 天前
uniapp微信小程序电子签名
微信小程序·小程序·uni-app
梦夏夜1 天前
微信小程序订单发货管理接入
微信小程序·小程序·发货信息管理
2401_845935681 天前
Java UU跑腿同城跑腿小程序源码快递代取帮买帮送源码小程序+H5+公众号跑腿系统
微信·微信小程序·小程序·微信公众平台·微信开放平台
2401_845936451 天前
Java UU跑腿同城跑腿小程序源码快递代取帮买帮送源码小程序+H5+公众号跑腿系统
微信·微信小程序·小程序·微信公众平台·微信开放平台