Closed er-aman-gupta closed 2 years ago
Not a bug, but incomplete documentation led to this issue. Going through the example i found out this piece of code
final session = await AudioSession.instance;
await session.configure(AudioSessionConfiguration(
avAudioSessionCategory: AVAudioSessionCategory.playAndRecord,
avAudioSessionCategoryOptions:
AVAudioSessionCategoryOptions.allowBluetooth |
AVAudioSessionCategoryOptions.defaultToSpeaker,
avAudioSessionMode: AVAudioSessionMode.spokenAudio,
avAudioSessionRouteSharingPolicy:
AVAudioSessionRouteSharingPolicy.defaultPolicy,
avAudioSessionSetActiveOptions: AVAudioSessionSetActiveOptions.none,
androidAudioAttributes: const AndroidAudioAttributes(
contentType: AndroidAudioContentType.speech,
flags: AndroidAudioFlags.none,
usage: AndroidAudioUsage.voiceCommunication,
),
androidAudioFocusGainType: AndroidAudioFocusGainType.gain,
androidWillPauseWhenDucked: true,
));
This is not mention in documentation but is important for iOS app to work.
Can someone do a PR with an updated doc?
Not a bug, but incomplete documentation led to this issue. Going through the example i found out this piece of code
final session = await AudioSession.instance; await session.configure(AudioSessionConfiguration( avAudioSessionCategory: AVAudioSessionCategory.playAndRecord, avAudioSessionCategoryOptions: AVAudioSessionCategoryOptions.allowBluetooth | AVAudioSessionCategoryOptions.defaultToSpeaker, avAudioSessionMode: AVAudioSessionMode.spokenAudio, avAudioSessionRouteSharingPolicy: AVAudioSessionRouteSharingPolicy.defaultPolicy, avAudioSessionSetActiveOptions: AVAudioSessionSetActiveOptions.none, androidAudioAttributes: const AndroidAudioAttributes( contentType: AndroidAudioContentType.speech, flags: AndroidAudioFlags.none, usage: AndroidAudioUsage.voiceCommunication, ), androidAudioFocusGainType: AndroidAudioFocusGainType.gain, androidWillPauseWhenDucked: true, ));
This is not mention in documentation but is important for iOS app to work.
where to add these code part? ios app doesnt work on real device despite workin on emulator
Audio Sessions are not anymore managed by Flutter Sound, since v9.0
When we released 9.0, someone promised to write a guide explaining how to use a Flutter plugin like "Audio_session" and a simple example, but he/she never completed his/her promise.
The documentation is in /doc/pages. The left side menu is in /doc/_data/sidebars/mydoc_sidebar.yml. Any PR are welcome.
@alperenbaskaya58 , Sorry for delayed response, You can just add this piece of code before opening the sound recorder. Have a look at the example project.
Thanks a lot for pointing that out, @er-aman-gupta . Adding those pieces of code fixed the problem of not being able to record audio on an iOS device.
Flutter Sound Version :
FULL or LITE flavor ? - FULL
Important: Result of the command :
flutter pub deps | grep flutter_sound
Severity
Crash ?
Result is not what expected ? - When recording audio file in iOS using the FlutterSoundRecorder and then playing it back using FlutterSoundPlayer, it throws an exception in logs
Cannot build my App ?
Minor issue ?
Platforms you faced the error
iOS ? Yes
Android ? No
Flutter Web ? Not applicable
Emulator ? No
Real device ? Yes
Describe the bug When recording audio file in iOS using the FlutterSoundRecorder and then playing it back using FlutterSoundPlayer, it throws an exception in logs
To Reproduce Can be reproduced by using the example given with the package https://github.com/Canardoux/flutter_sound/blob/8b5634ebf070fb56dd875bac81008a883b42f434/flutter_sound/example/lib/simple_recorder/simple_recorder.dart. Was able to replicate this with exact same code.
Logs!!!!
(This is very important. Most of the time we cannot do anything if we do not have information on your bug). To activate the logs, you must instantiate your modules with the Log Level set to
Level.debug
:See this