收藏
回答

自己定义video组件,requestFullScreen()在安卓机(华为,小米)出现故障?


问题:

自己定义了一个components,想实现点击视频后,全屏播放。在js文件中:方法一和方法二都会点击视频播放按钮出现闪屏,并且无法退出的问题,必须强退(暂忽略代码中currentvideo.requestFullScreen() 会随着bindplay方法多次触发,第一次触发就不行),ios(8及以上机型)暂未发现


测试机型:

机型 nova2s 微信7.0.9

机型 huawei p30 微信7.0.10

机型 mix3 微信7.0.9

..... 还有其他部分小米机型


小程序版本:

体验版

开发版



代码结构:



开发工具版本(基本采用默认):


app.json:

"usingComponents": {
    "auto-video""/components/autovideo/autovideo"
  }



wxml文件:

<view class="" hover-class="none" hover-stop-propagation="false">
    <video class="autovideo-class"  
    id="{{currentvideoid}}"
    src="{{src}}" 
    direction="0"   
    bindplay="_bindplay"/>
</view>


js文件 :


Component({
    /**
     * 组件的属性列表
     */
    properties: {
        currentvideoid: {
            type: String
        },
        src: {
            type: String
        }
    },
    /**
     * 组件的初始数据
     */
    data: {
    },
    created() {
    },
    /**
     * 组件的方法列表
     */
    methods: {
        _bindplay(e) {
            let currentvideo = wx.createVideoContext(this.data.currentvideoid, this);
            if (currentvideo) {
                currentvideo.play();
                //method1
                setTimeout(() => {
                    currentvideo.requestFullScreen();
                }, 1000);
                //method2
                //currentvideo.requestFullScreen();
            }
        },
    },
    externalClasses: ['autovideo-class']
})
回答关注问题邀请回答
收藏

2 个回答

登录 后发表内容
问题标签