user3618276
user3618276

Reputation: 101

WebRTC: Selection from audio input devices

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

Answers (2)

user3618276
user3618276

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

Philipp Hancke
Philipp Hancke

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

Related Questions