Skip to content

Commit 3f67360

Browse files
committed
update example.
1 parent 23570b3 commit 3f67360

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

lib/src/rtc_video_element.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import 'dart:html' as html;
22

33
import '../dart_webrtc.dart';
4-
import 'media_stream_impl.dart';
54

65
class RTCVideoElement {
76
RTCVideoElement() {
@@ -61,4 +60,6 @@ class RTCVideoElement {
6160
void load() => _html.load();
6261

6362
void removeAttribute(String name) => _html.removeAttribute(name);
63+
64+
Future<void> setSinkId(String sinkId) => _html.setSinkId(sinkId);
6465
}

web/main.dart

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,15 @@ void loopBackTest() async {
3737
list.forEach((e) {
3838
print('${e.runtimeType}: ${e.label}, type => ${e.kind}');
3939
});
40-
41-
await navigator.mediaDevices.selectAudioOutput(AudioOutputOptions(
42-
deviceId: list
43-
.where((element) => element.kind == 'audiooutput')
44-
.last
45-
.deviceId));
40+
var sinkId =
41+
list.where((element) => element.kind == 'audiooutput').last.deviceId;
42+
try {
43+
await navigator.mediaDevices
44+
.selectAudioOutput(AudioOutputOptions(deviceId: sinkId));
45+
} catch (e) {
46+
print('selectAudioOutput error: ${e.toString()}');
47+
await localVideo.setSinkId(sinkId);
48+
}
4649

4750
var pc = await createPeerConnection({});
4851
pc.onAddStream = (MediaStream stream) {};

0 commit comments

Comments
 (0)