uniapp swiper 轮播视频 解决方案

思路 关闭自动轮播:autoplay="false"  关闭自动播放功能:autoplay="false",因为视频是循环播放的所以加上了loop,视频播放结束的时候,修改swiper的current,达到轮播效果,但是因为视频是循环播放的,所以需要在切换轮播的时候,暂停上一个轮播的视频,播放当前的视频。

 //视频结束
videoEnd() {
      this.$nextTick(() => {
        uni.createVideoContext(`myVideo${this.current}`, this).stop()
        if (this.current == this.list.length - 1) {
          this.current = 0
          uni.createVideoContext(`myVideo${this.current}`, this).play()
        } else {
          this.current += 1
          uni.createVideoContext(`myVideo${this.current}`, this).play()
        }
      })
    },

//轮播图切换
swiperChange(e) {
      this.current = e.detail.current
      uni.createVideoContext(`myVideo${this.current}`, this).play()
      this.list.forEach((item, index) => {
        if (item.type == 'video') {
          let temp = 'myVideo' + index
          if (index == this.current) {
            uni.createVideoContext('myVideo' + this.current, this).play()
          } else {
            uni.createVideoContext(temp, this).pause()
          }
        }

      })
    }

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值