Canardoux / flutter_sound

Flutter plugin for sound. Audio recorder and player.
Mozilla Public License 2.0
868 stars 568 forks source link

[BUG]: MissingPluginException when used in audio_service #674

Open trybnikova opened 3 years ago

trybnikova commented 3 years ago

Flutter Sound Version : 8.1.1

|-- flutter_sound 8.1.1 | |-- flutter_sound_platform_interface 8.1.1 | |-- flutter_sound_web 8.1.1 | | |-- flutter_sound_platform_interface...


Severity


Platforms you faced the error


Describe the bug I added the flutter_sound plugin to the example project of audio_service plugin and checked if I can start a recording in the AudioPlayerTask. The goal is to record sound at specific times while an audio player keeps playing even when the app is in the background. When I do that the plugin can't be found. At first I thought it might be the case because the background task runs in a separate isolate BUT I do use the path_provider plugin to define the file path and that is found and executed properly.

My forked repo: https://github.com/trybnikova/audio_service My changes: see last commit

To Reproduce Steps to reproduce the behavior:

  1. Clone the repo
  2. Open 'example' project
  3. Build and install on device
  4. Open 'Audio Service Demo' App settings and allow Microphone permission (no code was added to request it to keep it simple)
  5. Start the app
  6. Click 'AudioPlayer'

Logs!!!!

(This is very important. Most of the time we cannot do anything if we do not have information on your bug)

I/flutter (16652): /data/user/0/com.ryanheise.audioserviceexample/app_flutter/scene_recording.wav I/flutter (16652): FS:---> openAudioSession I/flutter (16652): ---> openAudioSession I/flutter (16652): Resetting flutter_sound Recorder Plugin E/flutter (16652): [ERROR:flutter/lib/ui/ui_dart_state.cc(186)] Unhandled Exception: MissingPluginException(No implementation found for method resetPlugin on channel com.dooboolab.flutter_sound_recorder) E/flutter (16652): #0 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:156:7) E/flutter (16652): E/flutter (16652): #1 FlutterSoundRecorder._openAudioSession (package:flutter_sound/public/flutter_sound_recorder.dart:393:9) E/flutter (16652): E/flutter (16652): #2 FlutterSoundRecorder.openAudioSession. (package:flutter_sound/public/flutter_sound_recorder.dart:355:11) E/flutter (16652): E/flutter (16652): #3 BasicLock.synchronized (package:synchronized/src/basic_lock.dart:33:16) E/flutter (16652): E/flutter (16652): #4 FlutterSoundRecorder.openAudioSession (package:flutter_sound/public/flutter_sound_recorder.dart:354:5) E/flutter (16652): E/flutter (16652): #5 AudioPlayerTask._testRecorder (package:audio_service_example/main.dart:333:5) E/flutter (16652): E/flutter (16652):


Larpoux commented 3 years ago

Hi @trybnikova ,

At first I thought it might be the case because the background task runs in a separate isolate

Do you mean that you use Flutter Sound from two different isolates ? If this is the case, I am not surprised that you get somme problems. I am not sure that it has never been tested by someone else.

I even do not know what Flutter does with the Native Plugins :

Your Problem Report is interesting. It needs to be inverstigate more.

trybnikova commented 3 years ago

Hi @Larpoux,

Do you mean that you use Flutter Sound from two different isolates ?

so I am new to Flutter and both plugins but from my understanding the AudioPlayerTask is a separate isolate. I try to use Flutter Sound in that isolate. It is not used in the main isolate where the UI is.

I did try out what happens when I use Flutter Sound in the main isolate and it did work, meaning the AudioPlayerTask was playing a song while the Flutter Sound was recording at the same time. But since I would like to start recording at different times later in the future where the app might be in the background, I moved it into the AudioPlayerTask and that throws the exception I posted above.

github-actions[bot] commented 9 months ago

This issue is stale because it has been open 90 days with no activity. Leave a comment or this will be closed in 7 days.