Open mhstoller opened 3 years ago
Did you open your Audio Session before calling setAudioFocus()
?
What are the parameters that you give to setAudioFocus()
?
Note : I plan to clean the Audio Focus handling very soon.
Did you open your Audio Session before calling
setAudioFocus()
? What are the parameters that you give tosetAudioFocus()
?Note : I plan to clean the Audio Focus handling very soon.
Yes, I opened the audio session. Any parameters in setAudioFocus cause the error, I am calling it like this:
await recorder.openAudioSession(
focus: AudioFocus.doNotRequestFocus,
);
//Later on in the code (causes error)
await recorder.setAudioFocus(
focus: AudioFocus.requestFocusAndStopOthers,
mode: SessionMode.modeVoiceChat,
category: SessionCategory.playAndRecord,
);
//Stop recording
await recorder.stopRecorder();
await recorder.setAudioFocus(focus: AudioFocus.abandonFocus); //causes error
It happens using the default constructor as well; recorder.setAudioFocus()
. The same code works on iOS with no error
I am going to clean this f***ing Audio Focus handling. I will look to your issue. Please keep it open.
await soundRecorder?.setAudioFocus(
focus: AudioFocus.requestFocusAndStopOthers); // error on this line
version : flutter_sound_lite: ^8.5.0 Flutter version : 3.10.6 device : Redmi 6A (Physical device) Android version : Android 9 (API 28)
I/flutter (21126): ┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
I/flutter (21126): │ #0 FlutterSoundRecorder.setAudioFocus (package:flutter_sound_lite/public/flutter_sound_recorder.dart:870:13)
I/flutter (21126): │ #1 SoundRecorder.record (package:maiacare/screens/care_notes/view/audio_recorder.dart:59:28)
I/flutter (21126): ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
I/flutter (21126): │ 🐛 FS:---> setAudioFocus
I/flutter (21126): └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
I/flutter (21126): ┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
I/flutter (21126): │ #0 FlutterSoundRecorder._setAudioFocus (package:flutter_sound_lite/public/flutter_sound_recorder.dart:887:13)
I/flutter (21126): │ #1 FlutterSoundRecorder.setAudioFocus.
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.
This issue should be analysed
Flutter Sound Version :
FULL or LITE flavor: Lite
Important: Result of the command :
flutter pub deps | grep flutter_sound
Severity
Platforms you faced the error
Android 10 physical device
Your problem
Describe the bug calling setAudioFocus throws a "Failed to handle method call" error
To Reproduce Steps to reproduce the behavior:
Logs