Skip to content
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

Interoperability problem using microphone #17

Open
agbossi opened this issue Feb 12, 2024 · 0 comments
Open

Interoperability problem using microphone #17

agbossi opened this issue Feb 12, 2024 · 0 comments

Comments

@agbossi
Copy link

agbossi commented Feb 12, 2024

I'm getting the following error when using microphone api

Error: Assertion failed: org-dartlang-sdk:///dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/types.dart:217:7
isJsObject(f) ||
!JS('bool', '# instanceof #.Function', f, global
)
"Dart function requires allowInterop to be passed to JavaScript."
dart-sdk/lib/internal/js_dev_runtime/private/ddc_runtime/errors.dart 294:3 throw
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 35:3 assertFailed
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/types.dart 218:59 assertInterop
dart-sdk/lib/_internal/js_dev_runtime/private/js_helper.dart 853:31 assertInterop$
dart-sdk/lib/_internal/js_dev_runtime/private/js_array.dart 220:7 forEach]
dart-sdk/lib/_internal/js_dev_runtime/private/js_helper.dart 858:51 assertInteropArgs
dart-sdk/lib/_internal/js_shared/lib/js_util_patch.dart 109:3 callMethod$
packages/typings/src/d/typescript/lib.dom.d.dart 94672:9 MediaRecorder$36Typings._addEventListener$362
packages/typings/src/d/typescript/lib.dom.d.dart 94670:17

The function that triggers the error is this:

  @override
  void startRecording() async {
    final _constraints = {
      'audio': {'channelCount': 1, 'sampleRate': 48000}
    };

    final ty.MediaStreamConstraints _mediaConstraints =
        ty.MediaStreamConstraints(audio: _constraints);
    _mediaStream =
        await ty.window.navigator.mediaDevices.getUserMedia(_mediaConstraints);

    _setupAudioGraph(_mediaStream);
    _mediaRecorder = ty.MediaRecorder(_mediaStream);
    _mediaRecorder.addEventListener.$2('dataavailable', _onDataAvailable);

    _mediaRecorder.start();
  }

The error occurs in
_mediaRecorder.addEventListener.$2('dataavailable', _onDataAvailable);

The debugger stops in typings-0.0.6+1/lib/src/d/typescript/lib.dom.d.dart here:

  _i2.Future<_i3.MediaStream> Function([_i3.MediaStreamConstraints?])
      get getUserMedia => ([_i3.MediaStreamConstraints? p0]) =>
          _i4.promiseToFuture(_i4.callMethod(
            _i4.getProperty(
              this,
              'getUserMedia',
            ),
            r'call',
            [
              this,
              p0 ?? _i6.undefined,
            ],
          ));

Am I missing something? The error doesn't depend on the content of _onDataAvailable
I'm using Dart 3.2.6 and Flutter 3.16.9

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant