flutter_sound: [BUG]:Record audio is not working in web.

Flutter Sound Version :

flutter_sound: ^8.1.9

Severity

  • NoSuchMethodError: tried to call a non-function, such as null: ‘dart.global.newRecorderInstance’

Platforms you faced the error

  • Flutter Web

Describe the bug when I call openAudioSession then i get this error.

openAudioSession(
        focus: AudioFocus.requestFocusAndDuckOthers,
        category: SessionCategory.record,
      )

To Reproduce Steps to reproduce the behavior:

StreamController<Food> recordingDataController = StreamController<Food>();

 await recorder.openAudioSession(
        focus: AudioFocus.requestFocusAndDuckOthers,
        category: SessionCategory.record,
      );
      await recorder.startRecorder(
        codec: Codec.pcm16,
        numChannels: 1,
        sampleRate: 48000,
        toStream: recordingDataController.sink,
      );

Logs!!!

FS:—> openAudioSession —> openAudioSession Resetting flutter_sound Recorder Plugin —> resetPlugin <— resetPlugin NoSuchMethodError: tried to call a non-function, such as null: ‘dart.global.newRecorderInstance’


About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 38 (1 by maintainers)

Most upvoted comments

Did you include the javascript files into your xxx.html file ?

Look to this or this

For those with error dart.global.newPlayerInstance or dart.global.newRecorderInstance is not a function, after you include 4 extra lines in header of index.html, you need to do a hard reload web page (Chrome: F12, right click on refresh button). That is what happened to me.

try :

<script src="https://cdn.jsdelivr.net/npm/tau_sound_core@8.1.9/js/flutter_sound/flutter_sound.min.js"></script>
  <script src="https://cdn.jsdelivr.net/npm/tau_sound_core@8.1.9/js/flutter_sound/flutter_sound_player.min.js"></script>
  <script src="https://cdn.jsdelivr.net/npm/tau_sound_core@8.1.9/js/flutter_sound/flutter_sound_recorder.min.js"></script>
  <script src="https://cdn.jsdelivr.net/npm/howler@2/dist/howler.min.js"></script>