赞
踩
- <video src='{{item.fileUrl}}' data-index="{{index}}" id="{{index}}"
- bindtap="video_play" show-fullscreen-btn='{{false}}'>
- </video>
- data: {
- indexCurrent:null,
- },
-
- // 点击cover播放,其它视频结束
- video_play(e) {
- var curIdx = e.currentTarget.id;
- // 没有播放时播放视频
- if (!this.data.indexCurrent) {
- this.setData({
- indexCurrent: curIdx
- })
- var videoContext = wx.createVideoContext(curIdx,this) //这里对应的视频id
- videoContext.play()
- } else {
- // 有播放时先将prev暂停,再播放当前点击的current
- var videoContextPrev = wx.createVideoContext(this.data.indexCurrent,this)
- //this是在自定义组件下,当前组件实例的this,以操作组件内 video 组件
- if (this.data.indexCurrent != curIdx) {
- videoContextPrev.pause()
- this.setData({
- indexCurrent: curIdx
- })
- var videoContextCurrent = wx.createVideoContext(curIdx,this)
- videoContextCurrent.play()
- }
- }
- },
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。