WebRTC:从音频输入设备中选择
WebRTC: Selection from audio input devices
这用于 selection 音频输出,方法是将接收器 ID 设置为 deviceId。
$('#outputAudio')[0].setSinkId(device_id);
是否可以用类似的方式select音频输入设备(麦克风)?
您需要使用设备 ID 调用 getUserMedia。 https://webrtc.github.io/samples/src/content/devices/input-output/ 显示了它的规范样本。
现在我知道可以通过将 deviceId 设置为 getUserMedia 音频约束来实现此选项。它看起来像这样:
constraints: {
"audio": {
"deviceId": "xkcTfaf1uUJ/q1po904WtoZqV1P/rsUjp889EOO0j6Q="
},
"video": false
}
navigator.mediaDevices.getUserMedia(constraints)
.then(function(mediaStream) {
// do something
}).catch(function(err) {
// do something
});
这用于 selection 音频输出,方法是将接收器 ID 设置为 deviceId。
$('#outputAudio')[0].setSinkId(device_id);
是否可以用类似的方式select音频输入设备(麦克风)?
您需要使用设备 ID 调用 getUserMedia。 https://webrtc.github.io/samples/src/content/devices/input-output/ 显示了它的规范样本。
现在我知道可以通过将 deviceId 设置为 getUserMedia 音频约束来实现此选项。它看起来像这样:
constraints: {
"audio": {
"deviceId": "xkcTfaf1uUJ/q1po904WtoZqV1P/rsUjp889EOO0j6Q="
},
"video": false
}
navigator.mediaDevices.getUserMedia(constraints)
.then(function(mediaStream) {
// do something
}).catch(function(err) {
// do something
});