直播推流组件按照官方调用之后,点击开始一点反应也没有,也不报错,不知道原因在哪里?是我没有权限吗?
发布于 6 年前 作者 songming 4950 次浏览 来自 官方Issues
<view class="page-body">
  <view class="page-section tc">
    <live-pusher id="pusher" url="直播推流地址" mode="RTC" autopush bindstatechange="statechange" />
    <view class="btn-area">
      <button bindtap="bindStart" class="page-body-button" type="primary">播放推流</button>
      <button bindtap="bindPause" class="page-body-button" type="primary">暂停推流</button>
      <button bindtap="bindStop" class="page-body-button" type="primary">停止推流</button>
      <button bindtap="bindResume" class="page-body-button" type="primary">恢复推流</button>
      <button bindtap="bindSwitchCamera" class="page-body-button" type="primary">切换前后摄像头</button>
    </view>
  </view>
</view>

js
  onReady(res) {
    this.ctx = wx.createLivePusherContext('pusher')
  },
  statechange(e) {
    console.log('live-pusher code:', e.detail.code)
  },
  bindStart() {
    this.ctx.start({
      successres => {
        console.log(1)
        console.log('start success')
      },
      failres => {
        console.log('start fail')
      }
    })
  },
  bindPause() {
    this.ctx.pause({
      successres => {
        console.log('pause success')
      },
      failres => {
        console.log('pause fail')
      }
    })
  },
  bindStop() {
    this.ctx.stop({
      successres => {
        console.log('stop success')
      },
      failres => {
        console.log('stop fail')
      }
    })
  },
  bindResume() {
    this.ctx.resume({
      successres => {
        console.log('resume success')
      },
      failres => {
        console.log('resume fail')
      }
    })
  },
  bindSwitchCamera() {
    this.ctx.switchCamera({
      successres => {
        console.log('switchCamera success')
      },
      failres => {
        console.log('switchCamera fail')
      }
    })
  },
1 回复

live-pusher 组件是需要特定的类目的,看看有没有申请

https://developers.weixin.qq.com/miniprogram/dev/component/live-player.html

回到顶部