云点播短视频播放器 在组件中使用 wx.createVideoContext 不能操作视频
发布于 3 年前 作者 guiyinghuang 8306 次浏览 来自 官方Issues
    <cloud-player 
      class="video"
      appid="{{appid}}"
      fileid="{{fileid}}"
      playurl="{{playurl}}"
      playerid="myVideo"
      class="video"
      width="750rpx"
      height="428rpx">

      <view 
        wx:if="{{coverShow}}"
        class="my_video_cover" 
        catchtap="handleTapPlay">
      </view>
    </cloud-player>

Component({
  properties: {
    fileidString,
    playurlString,
  },
  data: {
    appid: 'xxxxxxxxx',
    coverShowtrue//是否显示视频遮罩
  },
  observers: {
    'playurl'function(src{
      if(src) {
        // 在自定义组件开发中,需要多传入一个表示组件本身的参数this
        this.videoContext = wx.createVideoContext('myVideo'this)
      }
    }
  },
  methods: {
    // 点击播放
    handleTapPlay(){
      console.log(this.videoContext)
      this.setData({
        coverShowfalse
      })
      setTimeout(_ => {
        console.log('调用播放')
        this.videoContext.play()//无效
      }, 200)
    },
  }
})
回到顶部