html:
<video :data-id="item.id" :key="item.id" :id="'video'+item.id" :src="item.videoUrl"
object-fit:fill enable-danmu danmu-btn controls webkit-playsinline playsinline
x5-video-player-type="h5" x5-video-orientation="portraint"
@play="playing" @pause="pause" @error="videoErrorCallback"
:danmu-list="danmuList" >
</video>
js:
playing(e) {
let currentId = 'video' + e.currentTarget.dataset.id;// 获取当前视频id
this.videoContent = uni.createVideoContext(currentId);
let trailer = this.dynListData;
trailer.forEach(function(item, index) { // 获取json对象并遍历, 停止非当前视频
if (item.videoUrl != null && item.videoUrl != "") {
let temp = 'video' + item.id;
if (temp != currentId) {
uni.createVideoContext(temp).pause(); //暂停视频播放事件
}
}
})
}