videoContext.play()间歇性播放不了?
根据网络状态的切换,想要在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();[代码][代码] [代码][代码]} [代码][代码] [代码][代码]}[代码][代码]})[代码]