Skip to content

Commit

Permalink
fix: fix ondevicechange for dart web.
Browse files Browse the repository at this point in the history
  • Loading branch information
cloudwebrtc committed Aug 4, 2022
1 parent 4c04b38 commit ded4c35
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/src/mediadevices_impl.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'dart:async';
import 'dart:html' as html;
import 'dart:js' as js;
import 'dart:js_util' as jsutil;
import 'package:webrtc_interface/webrtc_interface.dart';

Expand Down Expand Up @@ -169,7 +170,8 @@ class MediaDevicesWeb extends MediaDevices {
final mediaDevices = html.window.navigator.mediaDevices;
if (mediaDevices == null) throw Exception('MediaDevices is null');

jsutil.setProperty(mediaDevices, 'ondevicechange', listener);
jsutil.setProperty(mediaDevices, 'ondevicechange',
js.allowInterop((evt) => listener?.call(evt)));
} catch (e) {
throw 'Unable to set ondevicechange: ${e.toString()}';
}
Expand Down

0 comments on commit ded4c35

Please sign in to comment.