8000 Bug/367 by wer-mathurin · Pull Request #372 · flutter-webrtc/flutter-webrtc · GitHub
[go: up one dir, main page]

Skip to content

Bug/367 #372

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,5 @@ example/ios/Runner/GeneratedPluginRegistrant.m
example/ios/Runner/GeneratedPluginRegistrant.h
example/ios/Flutter/Generated.xcconfig
example/ios/Flutter/flutter_export_environment.sh
.vscode/launch.json
example/.vscode/launch.json
27 changes: 21 additions & 6 deletions lib/src/web/mediadevices_impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,20 @@ class MediaDevicesWeb extends MediaDevices {
mediaConstraints.putIfAbsent('audio', () => false);

final mediaDevices = html.window.navigator.mediaDevices;
final jsStream = await mediaDevices.getUserMedia(mediaConstraints);
return MediaStreamWeb(jsStream, 'local');

if (jsutil.hasProperty(mediaDevices, 'getUserMedia')) {
var args = jsutil.jsify(mediaConstraints);
final jsStream = await jsutil.promiseToFuture<html.MediaStream>(
jsutil.callMethod(mediaDevices, 'getUserMedia', [args]));

return MediaStreamWeb(jsStream, 'local');
} else {
final jsStream = await html.window.navigator.getUserMedia(
audio: mediaConstraints['audio'],
video: mediaConstraints['video'],
);
return MediaStreamWeb(jsStream, 'local');
}
} catch (e) {
throw 'Unable to getUserMedia: ${e.toString()}';
}
Expand Down Expand Up @@ -56,13 +68,16 @@ class MediaDevicesWeb extends MediaDevices {
@override
Future<List<dynamic>> getSources() async {
final devices = await html.window.navigator.mediaDevices.enumerateDevices();

final result = <dynamic>[];
for (final device in devices) {
var input = device as html.MediaDeviceInfo;
// info
result.add(<String, String>{
'deviceId': device.deviceId,
'groupId': device.groupId,
'kind': device.kind,
'label': device.label
'deviceId': input.deviceId,
'groupId': input.groupId,
'kind': input.kind,
'label': input.label
});
}
return result;
Expand Down
0