Fix:3002 【商城小程序】优化评论列表中多个视频不能同时播放,播放下一个视频自动暂停前一个正在播放的视频
This commit is contained in:
@@ -26,7 +26,9 @@
|
||||
:poster="item.video + '?vframe/jpg/offset/1'"
|
||||
controls
|
||||
play-btn-position="center"
|
||||
:id="'video' + evaluateWtapperIndex"
|
||||
class="image"
|
||||
@play="pauseOtherVideo('video' + evaluateWtapperIndex)"
|
||||
/>
|
||||
</view>
|
||||
<view
|
||||
@@ -56,7 +58,9 @@ export default {
|
||||
}
|
||||
},
|
||||
data: function() {
|
||||
return {};
|
||||
return {
|
||||
videoPlayers: []
|
||||
};
|
||||
},
|
||||
mounted: function() {},
|
||||
methods: {
|
||||
@@ -66,6 +70,18 @@ export default {
|
||||
current:imgs[index],
|
||||
urls:imgs
|
||||
})
|
||||
},
|
||||
// 播放视频时暂停其他视频
|
||||
pauseOtherVideo(video) {
|
||||
if(this.videoPlayers.includes(video)) {
|
||||
this.videoPlayers.forEach((item) => {
|
||||
if(item !== video) {
|
||||
uni.createVideoContext(item, this).pause();
|
||||
}
|
||||
})
|
||||
} else {
|
||||
this.videoPlayers.push(video);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user