vue:
<video class="video-card" :src="data.img" controls :id="'id'+data.id" @play="videoPlayHandle('id'+data.id)"></video>
data:
video: null,
methods:
videoPlayHandle(id) {
let newVideo = uni.createVideoContext(id);
console.log("newvideo:"+JSON.stringify(newVideo));
newVideo.id = id;
if (!this.video) {
this.video = newVideo;
this.video.play();
console.log(JSON.stringify(this.video)+"播放");
return
}
if (this.video.id !== newVideo.id) {
console.log("切换视频主体");
newVideo.play();
console.log("目前视频主体播放");
this.video.pause();
console.log("之前视频主体暂停");
this.video = newVideo;
console.log("播放主体切换");
}
},