diff --git a/lib/src/frame_cryptor_impl.dart b/lib/src/frame_cryptor_impl.dart index 30b0e4c..4666c41 100644 --- a/lib/src/frame_cryptor_impl.dart +++ b/lib/src/frame_cryptor_impl.dart @@ -400,7 +400,7 @@ class KeyProviderImpl implements KeyProvider { class FrameCryptorFactoryImpl implements FrameCryptorFactory { FrameCryptorFactoryImpl._internal() { - worker = web.Worker('e2ee.worker.dart.js'); + worker = web.Worker('e2ee.worker.dart.js'.toJS); worker.addEventListener( 'message', (web.MessageEvent msg) { diff --git a/lib/src/mediadevices_impl.dart b/lib/src/mediadevices_impl.dart index 52a1c03..1f3b5cb 100644 --- a/lib/src/mediadevices_impl.dart +++ b/lib/src/mediadevices_impl.dart @@ -59,21 +59,12 @@ class MediaDevicesWeb extends MediaDevices { return MediaStreamWeb(jsStream, 'local'); } else { - final streamCompleter = Completer(); - - web.window.navigator.getUserMedia( - web.MediaStreamConstraints( + final jsStream = await web.window.navigator.mediaDevices + .getUserMedia(web.MediaStreamConstraints( audio: mediaConstraints['audio'], video: mediaConstraints['video'], - ), - (web.MediaStream stream) { - streamCompleter.complete(stream); - }.toJS, - (JSAny err) { - streamCompleter.completeError(err); - }.toJS); - - final jsStream = await streamCompleter.future; + )) + .toDart; return MediaStreamWeb(jsStream, 'local'); } } catch (e) { @@ -93,19 +84,11 @@ class MediaDevicesWeb extends MediaDevices { jsutil.callMethod(mediaDevices, 'getDisplayMedia', [arg])); return MediaStreamWeb(jsStream, 'local'); } else { - final streamCompleter = Completer(); - - web.window.navigator.getUserMedia( - web.MediaStreamConstraints( + final jsStream = await web.window.navigator.mediaDevices + .getUserMedia(web.MediaStreamConstraints( video: jsutil.jsify({'mediaSource': 'screen'}), - audio: mediaConstraints['audio'] ?? false), - (web.MediaStream stream) { - streamCompleter.complete(stream); - }.toJS, - (JSAny err) { - streamCompleter.completeError(err); - }.toJS); - final jsStream = await streamCompleter.future; + audio: mediaConstraints['audio'] ?? false)) + .toDart; return MediaStreamWeb(jsStream, 'local'); } } catch (e) { diff --git a/pubspec.yaml b/pubspec.yaml index 2264bde..ebcf797 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -13,7 +13,7 @@ dependencies: meta: ^1.8.0 platform_detect: ^2.0.7 synchronized: ^3.0.0+3 - web: ^0.5.1 + web: ^1.0.0 webrtc_interface: ^1.2.0 dev_dependencies: