<video id="myVideo" bindplay="onPlayVideo" data-id="myVideo" src="http://wxsnsdy.tc.qq.com/105/20210/snsdyvideodownload?filekey=30280201010421301f0201690402534804102ca905ce620b1241b726bc41dcff44e00204012882540400&bizid=1023&hy=SH&fileparam=302c020101042530230204136ffd93020457e3c4ff02024ef202031e8d7f02030f42400204045a320a0201000400" enable-danmu danmu-btn controls></video>
<video id="myVideo1" bindplay="onPlayVideo" data-id="myVideo1" src="http://wxsnsdy.tc.qq.com/105/20210/snsdyvideodownload?filekey=30280201010421301f0201690402534804102ca905ce620b1241b726bc41dcff44e00204012882540400&bizid=1023&hy=SH&fileparam=302c020101042530230204136ffd93020457e3c4ff02024ef202031e8d7f02030f42400204045a320a0201000400" enable-danmu danmu-btn controls></video>
onPlayVideo: function (e) {
console.log(e)
let id = e.currentTarget.dataset.id
if (this.data.videoId != "" && this.data.videoId != id) {
let ctx = wx.createVideoContext(this.data.videoId, this)
ctx.stop()
this.data.videoId = id
} else {
this.data.videoId = id
}
},
在自定义组件中这种控制视频的方式没作用,在page 页面中是可以控制的
目前遇到的问题是,富文本中出现多个video标签,没法控制同时只能播放一个