<block wx:for="{{videoList}}" wx:key="index">
<view class="university-item">
<video class="myVideo" id="myVideo{{index}}" src="{{item.videoUrl}}" binderror="videoErrorCallback" danmu-list="{{danmuList}}" show-center-play-btn="{{false}}" show-play-btn="{{true}}" controls picture-in-picture-mode="{{['push', 'pop']}}" poster="{{item.coverUrl}}"></video>
<image wx:if="{{index!=indexCurrent}}" data-index="{{index}}" class="play-icon" src="../../assets/images/pageIcon/play_icon.png" bindtap="playVideo"></image>
</view>
</block>
data: {
videoList: [],
pageNum: 1,
hasLoadingOver: false,
isLoading: false,
hasEmptyList: false,
indexCurrent: null
},
playVideo(e) {
const curIdx = e.currentTarget.dataset.index
if (this.data.indexCurrent !== null) {
const videoContextPrev = wx.createVideoContext('myVideo' + this.data.indexCurrent)
if (this.data.indexCurrent !== curIdx) {
videoContextPrev.pause()
}
}
const videoContext = wx.createVideoContext('myVideo' + curIdx)
videoContext.play()
this.setData({
indexCurrent: curIdx
})
},
video标签不要放多个。一个页面就一个video标签就够了。官方建议都不要超3个。
你竟然还放在数组循环里
你好,请打印binderror排查。
这个效果类似于轮播图加视频 轮播?