Skip to content

Interoperability problem using microphone #17

@agbossi

Description

@agbossi

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions