Skip to content

Commit 23570b3

Browse files
committed
Add example for selectAudioOutput.
1 parent ded4c35 commit 23570b3

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

web/main.dart

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,25 @@ void loopBackTest() async {
2525
var localVideo = RTCVideoElement();
2626
local!.append(localVideo.htmlElement);
2727

28+
navigator.mediaDevices.ondevicechange = (event) async {
29+
var list = await navigator.mediaDevices.enumerateDevices();
30+
print('ondevicechange: ');
31+
list.where((element) => element.kind == 'audiooutput').forEach((e) {
32+
print('${e.runtimeType}: ${e.label}, type => ${e.kind}');
33+
});
34+
};
35+
2836
var list = await navigator.mediaDevices.enumerateDevices();
2937
list.forEach((e) {
3038
print('${e.runtimeType}: ${e.label}, type => ${e.kind}');
3139
});
3240

41+
await navigator.mediaDevices.selectAudioOutput(AudioOutputOptions(
42+
deviceId: list
43+
.where((element) => element.kind == 'audiooutput')
44+
.last
45+
.deviceId));
46+
3347
var pc = await createPeerConnection({});
3448
pc.onAddStream = (MediaStream stream) {};
3549
var stream =

0 commit comments

Comments
 (0)