html52.com
我爱小程序-开发者交流社区

videoContext.play()间歇性播放不了?

问题模块 框架类型 API/组件名称 终端类型 操作系统 微信版本 基础库版本
API和组件 小程序 wx.createVideoContext 客户端 iOS weChat 6.6.1 ios11.02

根据网络状态的切换,想要在wifi状态自动播放视频,非wifi下暂停播放。在开发者工具上效果没有问题。但是手机上测试,间歇性出现play()没有生效。

以下是我的代码,不知道是否我的处理方式存在问题


Page({
    data: {
 
    },
    onLoad: function(options){
        let that =this
        that.getclassList();
 
        // 网络切换的判断
        wx.onNetworkStatusChange(function(res) {
            var res = res.networkType
            that.getNetwork(res)
        })
    },
    getNetwork:function(res){
       let that = this
       that.videoContext = wx.createVideoContext('myVideo');
 
       if(res =='wifi'){ 
          that.videoContext.play()   
       }else{
          that.videoContext.pause();
       }
    }
})


评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

真正的个人免签约支付接口

云免签H5支付