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()
    }
});
相关推荐
weixin_lynhgworld1 小时前
从闲置到珍宝:旧物回收小程序系统重塑物品价值
小程序·旧物回收
2501_916007476 小时前
iOS App 上架实战 从内测到应用商店发布的全周期流程解析
android·ios·小程序·https·uni-app·iphone·webview
小小怪下士_---_11 小时前
uniapp开发微信小程序自定义导航栏
前端·vue.js·微信小程序·小程序·uni-app
fakaifa1 天前
点大餐饮独立版系统源码v1.0.3+uniapp前端+搭建教程
小程序·uni-app·php·源码下载·点大餐饮·扫码点单
说私域1 天前
基于开源 AI 大模型 AI 智能名片 S2B2C 商城小程序视角下的企业组织能力建设与破圈升级
人工智能·小程序
fakaifa2 天前
【最新版】CRMEB Pro版v3.4系统源码全开源+PC端+uniapp前端+搭建教程
人工智能·小程序·uni-app·php·crmeb·源码下载·crmebpro
2501_915918412 天前
iOS 应用上架全流程实践,从开发内测到正式发布的多工具组合方案
android·ios·小程序·https·uni-app·iphone·webview
上海云盾第一敬业销售2 天前
小程序被爬虫攻击,使用waf能防护吗?
爬虫·小程序
suncentwl2 天前
做一个答题pk小程序多少钱?
小程序·答题小程序·知识竞赛·答题pk软件
说私域2 天前
基于开源链动2+1模式AI智能名片S2B2C商城小程序的流量转化策略研究
人工智能·小程序