Fix:2886 【商城小程序】农民店铺-多个视频资讯可同时播放(优化为点击下一个视频播放时,上一个视频自动停止)

This commit is contained in:
modendeveloper
2024-12-18 23:18:33 +08:00
parent f64f87546e
commit 40431f03fc
3 changed files with 27 additions and 5 deletions
+1 -1
View File
@@ -163,7 +163,7 @@ export default {
name: '',
page: 1,
typeList: [],
typeIndex: 0,
typeIndex: -1,
// 当前选中的类型
currType: {},
cityName: '',
+1 -1
View File
@@ -95,7 +95,7 @@ export default {
posterUrl: '',
activeties: [],
id: '',
actived: -1,
actived: 1,
tabs: [
{name: '项目', value: 1},
{name: '文化', value: 2},
+25 -3
View File
@@ -32,6 +32,7 @@
:loop="false"
object-fit="contain"
play-btn-position="center"
id="coverVideo"
class="video"
/>
</view>
@@ -230,7 +231,8 @@
play-btn-position="center"
:show-fullscreen-btn="false"
class="video-item"
@play="infoItemViewClick(item)"
:id="'video-item' + index"
@play="infoItemViewClick(item, index)"
/>
</view>
<view v-else>
@@ -363,7 +365,8 @@ export default {
activeIndex: 0,
isLoadInfoListSuccess: false,
picColumnWidth: '325rpx',
infoArray: []
infoArray: [],
videoPlayers: []
}
},
onPageScroll(e) {
@@ -440,7 +443,26 @@ export default {
}
})
},
infoItemViewClick(item) {
infoItemViewClick(item, index) {
if(item.type === 2) {
const coverCtx = uni.createVideoContext('coverVideo', this)
coverCtx.pause()
const playerId = 'video-item' + index
if(this.videoPlayers.includes(playerId)) {
this.videoPlayers.forEach(player => {
if(player === playerId) return
const playerCtx = uni.createVideoContext(player, this)
playerCtx.pause()
})
} {
this.videoPlayers.push(playerId)
this.videoPlayers.forEach(player => {
if(player === playerId) return
const playerCtx = uni.createVideoContext(player, this)
playerCtx.pause()
})
}
}
const params = {
countyFamousNewsId: item.id
}