自定义组件内wxml
<video id="myvideo2" src='https://peacebird-img.oss-cn-shanghai.aliyuncs.com/wx/2019-12-11-bar-12.mp4' enable-danmu danmu-btn controls>
<cover-view bindtap="videoPlayCover">
<cover-image class="img" src="http://ofstudio.com/tempimag/001.jpg" style="width: 50%;" />
</cover-view>
</video>
自定义组件内JS
methods: {
videoPlayCover() {
var video = wx.createVideoContext('myvideo2');
console.log(video)
video.play();
}
}
video.play(); //执行失败
wx.createVideoContext('myvideo2', this);
需要传递this上下文
没有问题,可以播放啊
1.微信开发者工具实测可以
2.小米8实测可以