File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -27,6 +27,28 @@ class MediaDevicesWeb extends MediaDevices {
2727 print (
2828 '[getUserMedia] failed to remove facingMode from mediaConstraints' );
2929 }
30+ try {
31+ if (mediaConstraints['audio' ] is Map <String , dynamic > &&
32+ Map .from (mediaConstraints['audio' ]).containsKey ('optional' ) &&
33+ mediaConstraints['audio' ]['optional' ]
34+ is List <Map <String , dynamic >>) {
35+ List <Map <String , dynamic >> optionalValues =
36+ mediaConstraints['audio' ]['optional' ];
37+ final audioMap = < String , dynamic > {};
38+
39+ optionalValues.forEach ((option) {
40+ option.forEach ((key, value) {
41+ audioMap[key] = value;
42+ });
43+ });
44+
45+ mediaConstraints['audio' ].remove ('optional' );
46+ mediaConstraints['audio' ].addAll (audioMap);
47+ }
48+ } catch (e, s) {
49+ print (
50+ '[getUserMedia] failed to translate optional audio constraints, $e , $s ' );
51+ }
3052
3153 final mediaDevices = web.window.navigator.mediaDevices;
3254
You can’t perform that action at this time.
0 commit comments