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()
    }
});
相关推荐
2501_915918411 小时前
iOS 上架全流程指南 iOS 应用发布步骤、App Store 上架流程、uni-app 打包上传 ipa 与审核实战经验分享
android·ios·小程序·uni-app·cocoa·iphone·webview
00后程序员张2 小时前
iOS App 混淆与加固对比 源码混淆与ipa文件混淆的区别、iOS代码保护与应用安全场景最佳实践
android·安全·ios·小程序·uni-app·iphone·webview
破无差12 小时前
《赛事报名系统小程序》
小程序·html·uniapp
00后程序员张13 小时前
详细解析苹果iOS应用上架到App Store的完整步骤与指南
android·ios·小程序·https·uni-app·iphone·webview
海绵宝宝不喜欢侬14 小时前
uniapp-微信小程序分享功能-onShareAppMessage
微信小程序·小程序·uni-app
2501_9151063214 小时前
Xcode 上传 ipa 全流程详解 App Store 上架流程、uni-app 生成 ipa 文件上传与审核指南
android·macos·ios·小程序·uni-app·iphone·xcode
亮子AI15 小时前
【小程序】微信小程序隐私协议
微信小程序·小程序
weixin_1772972206916 小时前
短剧小程序系统开发:打造个性化娱乐新平台
小程序·娱乐·短剧
weixin_lynhgworld16 小时前
剧本杀小程序系统开发:开启沉浸式社交娱乐新纪元
小程序·娱乐
~废弃回忆 �༄18 小时前
mobx-miniprogram小程序的数据传输
小程序