我正在研究webRTC。现在我正在使用回声挑战,所以我在考虑麦克风切换技术。例如,用户A是通过关闭用户B的麦克风说话,反之亦然。webRTC实现了这个构建吗?如果不是,我怎样才能做到这一点呢?任何帮助都是非常感谢的。
发布于 2015-04-28 14:21:42
WebRTC没有内置这一点,因为这实际上更多地与媒体表示层相关。SimpleWebRTC通过attachMediaStream模块使用的一个很好的策略是简单地将本地参与者的媒体附加到仅用于音频的视频(或音频)元素上。
在该模块这里的主文件中找到的相关代码。这是:
if (!element) {
element = document.createElement(opts.audio ? 'audio' : 'video');
} else if (element.tagName.toLowerCase() === 'audio') {
opts.audio = true;
}
// Mute the video element so the local participant's audio doesn't play - do this only for the local participant, not the remote participants
if (opts.muted) element.muted = true;
// attach the stream to the element
if (typeof element.srcObject !== 'undefined') {
element.srcObject = stream;
}https://stackoverflow.com/questions/29912192
复制相似问题