直播推流组件按照官方调用之后,点击开始一点反应也没有,也不报错,不知道原因在哪里?是我没有权限吗?
<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({
success: res => {
console.log(1)
console.log('start success')
},
fail: res => {
console.log('start fail')
}
})
},
bindPause() {
this.ctx.pause({
success: res => {
console.log('pause success')
},
fail: res => {
console.log('pause fail')
}
})
},
bindStop() {
this.ctx.stop({
success: res => {
console.log('stop success')
},
fail: res => {
console.log('stop fail')
}
})
},
bindResume() {
this.ctx.resume({
success: res => {
console.log('resume success')
},
fail: res => {
console.log('resume fail')
}
})
},
bindSwitchCamera() {
this.ctx.switchCamera({
success: res => {
console.log('switchCamera success')
},
fail: res => {
console.log('switchCamera fail')
}
})
},
1 回复
live-pusher 组件是需要特定的类目的,看看有没有申请
https://developers.weixin.qq.com/miniprogram/dev/component/live-player.html