- 当前 Bug 的表现(可附上截图)
- 预期表现
- 复现路径
- 提供一个最简复现 Demo
wxml:
id="livePusher"
url="{{pushUrl}}"
mode="RTC"
bindstatechange="pusherStateChange"
binderror="onPushError"
enable-camera="{{false}}"
beauty="6"
class="invisible">js:
onReady: function () {
console.log('>>>on ready')
var self = this;
this.createPushContext(self);
this.createPlayContext(self);
wx.setKeepScreenOn({
keepScreenOn: true,
})
},
//初始化推流
createPushContext: function (self) {
console.log('>>> push create context');
var context = wx.createLivePusherContext('livePusher', self);
this.setData({
pushVideoContext: context
})
},
//推流
startPush: function(url){
console.log('>>> start pushing');
var that = this;
that.setData({
pushUrl: url
}, function () {
that.data.pushVideoContext.start();
})
},
//停止推流
stopPush: function(){
console.log('>>> stop pushing');
var that = this;
that.setData({
isPushing: false,
}, function () {
that.data.pushVideoContext.stop();
})
},
pusherStateChange: function (e) {
console.log('>>> live-pusher onPushStateChange:', e.detail.code);
if (e.detail.code == -1307) {
this.stopPush();
wx.showToast({
title: '-1307,推流失败',
})
} else if (e.detail.code == 1007) {
wx.hideToast();
// 推流成功
this.setData({
isPushing: true
})
}
},
onPushError: function (e) {
console.log('>>>push error:',e)
console.error('>>> live-pusher onPushError:', e.detail.errMsg);
this.stopPush();
wx.showToast({
title: '推流失败',
icon: 'none'
})
},
微信小程序开发问题解答
微信小程序开发者回答:
live-pusher 组件目前正在重构,后续版本会更新,如果之后还存在这个错误可以再反馈一下。
微信小程序开发者回答:
这是报图片的问题?
微信小程序开发者回答:
我发现,只要删掉那个组件里的 binderror="onPushError" 属性就可以了。。。
本文网址:http://www.91bianli.com/weixinxiaochengxu/15662.html