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