Skip to content

Commit

Permalink
fix: translate audio constraints for web
Browse files Browse the repository at this point in the history
  • Loading branch information
td-famedly committed Jun 5, 2024
1 parent ea029c2 commit dc362d5
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions lib/src/mediadevices_impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,28 @@ class MediaDevicesWeb extends MediaDevices {
print(
'[getUserMedia] failed to remove facingMode from mediaConstraints');
}
try {
if (mediaConstraints['audio'] is Map<String, dynamic> &&
Map.from(mediaConstraints['audio']).containsKey('optional') &&
mediaConstraints['audio']['optional']
is List<Map<String, dynamic>>) {
List<Map<String, dynamic>> optionalValues =
mediaConstraints['audio']['optional'];
final audioMap = <String, dynamic>{};

optionalValues.forEach((option) {
option.forEach((key, value) {
audioMap[key] = value;
});
});

mediaConstraints['audio'].remove('optional');
mediaConstraints['audio'].addAll(audioMap);
}
} catch (e, s) {
print(
'[getUserMedia] failed to translate optional audio constraints, $e, $s');
}

final mediaDevices = web.window.navigator.mediaDevices;

Expand Down

0 comments on commit dc362d5

Please sign in to comment.