8000 Bug/367 (#372) · tmthecoder/flutter-webrtc@c4f8a91 · GitHub
[go: up one dir, main page]

Skip to content

Commit c4f8a91

Browse files
authored
* Replace html_dart2js implementation with JS * add launch.json to gitignore
1 parent dcd84a6 commit c4f8a91

File tree

2 files changed

+23
-6
lines changed

2 files changed

+23
-6
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,5 @@ example/ios/Runner/GeneratedPluginRegistrant.m
1919
example/ios/Runner/GeneratedPluginRegistrant.h
2020
example/ios/Flutter/Generated.xcconfig
2121
example/ios/Flutter/flutter_export_environment.sh
22+
.vscode/launch.json
23+
example/.vscode/launch.json

lib/src/web/mediadevices_impl.dart

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,20 @@ class MediaDevicesWeb extends MediaDevices {
2424
mediaConstraints.putIfAbsent('audio', () => false);
2525

2626
final mediaDevices = html.window.navigator.mediaDevices;
27-
final jsStream = await mediaDevices.getUserMedia(mediaConstraints);
28-
return MediaStreamWeb(jsStream, 'local');
27+
28+
if (jsutil.hasProperty(mediaDevices, 'getUserMedia')) {
29+
var args = jsutil.jsify(mediaConstraints);
30+
final jsStream = await jsutil.promiseToFuture<html.MediaStream>(
31+
jsutil.callMethod(mediaDevices, 'getUserMedia', [args]));
32+
33+
return MediaStreamWeb(jsStream, 'local');
34+
} else {
35+
final jsStream = await html.window.navigator.getUserMedia(
36+
audio: mediaConstraints['audio'],
37+
video: mediaConstraints['video'],
38+
);
39+
return MediaStreamWeb(jsStream, 'local');
40+
}
2941
} catch (e) {
3042
throw 'Unable to getUserMedia: ${e.toString()}';
3143
}
@@ -56,13 +68,16 @@ class MediaDevicesWeb extends MediaDevices {
5668
@override
5769
Future<List<dynamic>> getSources() async {
5870
final devices = await html.window.navigator.mediaDevices.enumerateDevices();
71+
5972
final result = <dynamic>[];
6073
for (final device in devices) {
74+
var input = device as html.MediaDeviceInfo;
75+
// info
6176
result.add(<String, String>{
62-
'deviceId': device.deviceId,
63-
'groupId': device.groupId,
64-
'kind': device.kind,
65-
'label': device.label
77+
'deviceId': input.deviceId,
78+
'groupId': input.groupId,
79+
'kind': input.kind,
80+
'label': input.label
6681
});
6782
}
6883
return result;

0 commit comments

Comments
 (0)
0