voip-room 可正常运行代码。
发布于 4 年前 作者 fuxiulan 4136 次浏览 来自 分享


经测试,以下解决多人进入黑屏的正常代码。

joinvoip(){

var _this=this

//加入 (创建) 实时语音通话

wx.joinVoIPChat({

signature: signature,

nonceStr: nonceStr,

timeStamp: timeStamp,

groupId: groupId,

roomType: 'video',

success(res){

wx.hideLoading();

console.log(res)

_this.setData({

openIdList: res.openIdList,

})



//监听实时语音通话成员视频状态变化事件。

wx.onVoIPVideoMembersChanged(_this.handleVideoMemberChange);

//监听实时语音通话成员在线状态变化事件。有成员加入/退出通话时触发回调

wx.onVoIPChatMembersChanged(_this.handleChatMemberChange);


//监听实时语音通话成员通话状态变化事件。有成员开始/停止说话时触发回调

wx.onVoIPChatSpeakersChanged(function(res){

console.log('监听实时语音通话成员在线状态变化事件',res)

_this.setData({

speakerList: res.openIdList,

})

})

},


fail(err){

wx.hideLoading();

console.error('err',err)

_this.setData({

joinVoIPChat:'fail' + err.errCode + err.errMsg

})

}

})

},



handleChatMemberChange(data){

console.log('handleChatMemberChange', data.openIdList);

this.setData({

openIdList: data.openIdList

})

},

handleVideoMemberChange(data){

//订阅视频画面成员。对于视频房间,当成员超过两人时需进行订阅,否则只能看到最先加入房间的两人画面

wx.subscribeVoIPVideoMembers({

openIdList: data.openIdList

})

},



回到顶部