web rts 本地混流 pushClient.startMicrophone 失败报:InvalidStateError
是什么原因呢?
快速接入的模式可以,混流模式就不行。
async getLocalStream() {
let isMix = true;
if (!isMix) {
//快速接入
this.cameraStreamId = await this.pushClient.startCamera();
this.micStreamId = await this.pushClient.startMicrophone();
} else {
//开启本地混流模式前设置
this.videoEffectManager.setMixingConfig({
videoWidth: this.width,
videoHeight: this.height,
videoFramerate: 30
});
//开启本地混流模式
this.videoEffectManager.enableMixing(true);
//判断有没有摄像头可以用,有的话取一个 cameraStreamId
if (this.cameraList.length > 0) {
this.cameraStreamId = await this.pushClient.startCamera(this.cameraList[0].deviceId);
}
//设置视频流
if (this.cameraStreamId != null) {
this.videoEffectManager.setLayout([
{ streamId: this.cameraStreamId, x: (this.width - 24) / 2, y: (this.height - 100) / 2, width: this.width, height: this.height, zOrder: 1 }
]);
}
try {
//判断有没有麦克风可以用,有的话取一个 micStreamId
if (this.micList.length > 0) {
this.micStreamId = await this.pushClient.startMicrophone(this.micList[0].deviceId);
console.log(this.micStreamId, '取到的要混入的音频流 id')
}
} catch (e) {
console.log(e, '采集麦克风失败')
}
//设置音频流
if (this.micStreamId != null) {
this.audioEffectManager.setVolume(50, this.micStreamId);
this.pushClient.addCustomStream(this.micStreamId);
}
}
},
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。