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()
    }
});
相关推荐
毕设源码-朱学姐1 小时前
【开题答辩全过程】以 基于Java的医务室病历管理小程序为例,包含答辩的问题和答案
java·开发语言·小程序
文人sec2 小时前
微信小程序minium自动化测试SOP
微信小程序·小程序
克里斯蒂亚诺更新2 小时前
微信小程序 点击地图后弹出一个模态框
微信小程序·小程序·notepad++
云起SAAS2 小时前
患者随访管理抖音快手微信小程序看广告流量主开源
微信小程序·小程序·ai编程·看广告变现轻·患者随访管理
2501_916008892 小时前
HTTPS 请求抓包,从原理到落地排查的工程化指南(Charles / tcpdump / Wireshark / Sniffmaster)
ios·小程序·https·uni-app·wireshark·iphone·tcpdump
2501_9159090615 小时前
WebView 调试工具全解析,解决“看不见的移动端问题”
android·ios·小程序·https·uni-app·iphone·webview
说私域17 小时前
“开源链动2+1模式AI智能名片S2B2C商城小程序”在拉群营销中的应用与效果
人工智能·小程序
2501_9151063217 小时前
App 怎么上架 iOS?从准备资料到开心上架(Appuploader)免 Mac 上传的完整实战流程指南
android·macos·ios·小程序·uni-app·iphone·webview
环信即时通讯云20 小时前
实现小程序 uniApp 输入框展示自定义表情包
小程序·uni-app
2501_915921431 天前
iOS 抓不到包怎么办?工程化排查与替代抓包方案(抓包/HTTPS/Charles代理/tcpdump)
android·ios·小程序·https·uni-app·iphone·tcpdump