Reputation: 101
This is used for selection audio output by setting sink ID to deviceId.
$('#outputAudio')[0].setSinkId(device_id);
Is it possible to select an audio input device (microphone) in a similar way?
Upvotes: 1
Views: 4097
Reputation: 101
Now I know that this option is possible by setting deviceId to getUserMedia audio constraints. It looks something like that:
constraints: {
"audio": {
"deviceId": "xkcTfaf1uUJ/q1po904WtoZqV1P/rsUjp889EOO0j6Q="
},
"video": false
}
navigator.mediaDevices.getUserMedia(constraints)
.then(function(mediaStream) {
// do something
}).catch(function(err) {
// do something
});
Upvotes: 1
Reputation: 17350
You need to call getUserMedia with a device id. https://webrtc.github.io/samples/src/content/devices/input-output/ shows the canonical sample for that.
Upvotes: 1