-
-
Notifications
You must be signed in to change notification settings - Fork 89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Toogling audio output between earpiece and speaker #9
Comments
Hi @mmartinalo , the eventual goal is to implement all of the AVAudioSession API but I started with just the features that I personally needed. If you take a look at the source documentation for Apple's AVAudioSession , perhaps you can identify which features you need, then you can let me know and I can add those features next. |
Hello @ryanheise , I was reading in-depth the documentation and I realized that AVAudioSession playAndRecord category solve my problems:
Both for android and ios the code would be something like final session = await AudioSession.instance;
final AndroidAudioAttributes currentAndroidAttributes = session.configuration.androidAudioAttributes;
await session.configure(
session.configuration.copyWith(
androidAudioAttributes: AndroidAudioAttributes(
usage: AndroidAudioUsage.voiceCommunication,
flags: currentAndroidAttributes.flags,
contentType: currentAndroidAttributes.contentType,
),
avAudioSessionCategory: AVAudioSessionCategory.playAndRecord,
),
); I think it would be interesting to encapsulate a similar logic in a public function in the AudioPlayer. Thanks for the support! |
Glad you found a solution. I'd rather have a clear separation of concerns between these two plugins so that audio_session is responsible for switching between devices or detecting when a switch occurs, while just_audio doesn't need to know. Interestingly, the name "just" audio actually stemmed from a goal to build an audio plugin that didn't take on any other responsibilities besides the audio signal itself, while different plugins could handle settings for the hardware devices, etc. |
thanks , you saved my time :X |
Would you mind sharing your solution on this issue? #37 The goal of that issue is to provide a convenience method in the |
Context
I am developing a mobile application that plays audios with the packages just_audio and audio_service. I am trying to add a feature using the proximity sensors of the device so that every time the user brings the mobile closer to the ear, the audio is played from the earpiece
Dependencies
My current state
When the service starts I configure the AudioSession as following
And I have a custom action when the proximity sensor is actived
It is working properly on Android but I am not sure if it is the recommended way and I have no idea how to do it in ios with the available options avAudioSessionCategory, avAudioSessionCategoryOptions or avAudioSessionMode
Thank you in advance.
The text was updated successfully, but these errors were encountered: