问题描述
我们使用React Native WebRTC和Janus Gateway创建一个应用程序。它可以根据需要工作。我们的应用基于即按即说。因此,当处于收听模式的用户需要为其他应用程序断开麦克风时。并在有人按下语音按钮时收回。
突破麦克风:
if (!globalTrack) {
globalTracks = config.myStream.getTracks();
}
config.myStream.getTracks().forEach(t => {
config.myStream.removeTrack(t);
});
找回轨道:
globalTracks.forEach(t => {
config.myStream.addTrack(t);
});
pluginHandle.createOffer({
media: { addVideo: true },success: function(jsep) {
Janus.debug(jsep);
pluginHandle.send({message: {audio: true,video: false},"jsep": jsep });
},error: function(error) {
console.log("WebRTC error... " + JSON.stringify(error));
}
});
// also I have try this:
devices = await mediaDevices.getUserMedia({audio: true,video: false})
// devices output https://pastebin.ubuntu.com/p/KQqBq2QRy3/
devices._tracks.forEach(t => {
config.myStream.addTrack(t);
});
pluginHandle.createOffer({
media: {audio: {deviceid: devices._tracks[0]['id']},replaceAudio: true},success: function(jsep) {
pluginHandle.send({message: {audio: true,"jsep": jsep});
},error: function(error) {
console.log(("WebRTC error... " + JSON.stringify(error));
}
});
问题:
问题:例如:当有电话接到电话并接听电话时。即使重新启动应用程序,用户的声音也不会再通过。
在Janus Gateway上,一切正常。我认为问题在于重新谈判。
- 问题仅发生在Android手机上。并在强制停止应用程序后起作用。
Janus Gateway日志,当我在房间讲话时:
There's a message for JANUS AudioBridge plugin
Setting muted property: true (room 20,user 2301490876606211)
Notifying participant 329012611897879 (kardan)
Sending event to transport...
>> 0 (Success)
解决方法
我们找不到通用的解决方案。
目前,react-native-restart
可以重新启动应用程序