Skip to content

Commit

Permalink
Add example for selectAudioOutput.
Browse files Browse the repository at this point in the history
  • Loading branch information
cloudwebrtc committed Aug 4, 2022
1 parent ded4c35 commit 23570b3
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions web/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,25 @@ void loopBackTest() async {
var localVideo = RTCVideoElement();
local!.append(localVideo.htmlElement);

navigator.mediaDevices.ondevicechange = (event) async {
var list = await navigator.mediaDevices.enumerateDevices();
print('ondevicechange: ');
list.where((element) => element.kind == 'audiooutput').forEach((e) {
print('${e.runtimeType}: ${e.label}, type => ${e.kind}');
});
};

var list = await navigator.mediaDevices.enumerateDevices();
list.forEach((e) {
print('${e.runtimeType}: ${e.label}, type => ${e.kind}');
});

await navigator.mediaDevices.selectAudioOutput(AudioOutputOptions(
deviceId: list
.where((element) => element.kind == 'audiooutput')
.last
.deviceId));

var pc = await createPeerConnection({});
pc.onAddStream = (MediaStream stream) {};
var stream =
Expand Down

0 comments on commit 23570b3

Please sign in to comment.