Chinaunix首页 | 论坛 | 博客
  • 博客访问: 922102
  • 博文数量: 210
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 2070
  • 用 户 组: 普通用户
  • 注册时间: 2014-11-19 21:54
文章分类

全部博文(210)

文章存档

2020年(2)

2019年(18)

2018年(27)

2017年(5)

2016年(53)

2015年(88)

2014年(17)

分类: 其他平台

2018-06-04 17:26:10


点击(此处)折叠或打开

  1. bindplay: function (e) {

  2. var id = e.currentTarget.id //点击id

  3. console.log(this.data.playIndex) //正在播放的id

  4. if (!this.data.playIndex) { // 没有播放时播放视频

  5. this.setData({

  6. playIndex: id

  7. })

  8. //console.log(this.data.playIndex)

  9. var videoContext = wx.createVideoContext(id)

  10. videoContext.play()

  11. } else { // 有播放时先将prev暂停,再播放当前点击的current

  12. var videoContextPrev = wx.createVideoContext(this.data.playIndex)

  13. // videoContextPrev.seek(0)

  14. if (this.data.playIndex != id){ //不知道为什么,不加这个判断的时候这个视频会一直在播放和暂停之间切换

  15. videoContextPrev.pause()

  16. }

  17. this.setData({

  18. playIndex: id

  19. })

  20. var videoContextCurrent = wx.createVideoContext(this.data.playIndex)

  21. videoContextCurrent.play()

  22. }

  23. },

wx.createVideoContext(videoId, this)

创建并返回 video 上下文 videoContext 对象。在自定义组件下,第二个参数传入组件实例this,以操作组件内 

阅读(3316) | 评论(0) | 转发(0) |
0

上一篇:小程序模拟循环数据

下一篇:tab动画效果

给主人留下些什么吧!~~