Skip to content
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

Updating documentation for audio session configuration for background usage (iOS specific) #1103

Open
j-bbr opened this issue Jan 30, 2025 · 3 comments

Comments

@j-bbr
Copy link

j-bbr commented Jan 30, 2025

Documentation request for the following page(s)

https://pub.dev/documentation/audio_service/latest/

Section(s) in question

Configuring the audio session

Suggested improvement

I observed that using the audio_service in response to background events i.e location events as used in a navigation application requires specific configuration of the audio session to work on iOS.

If the session is configured with anything other than AVAudioSessionCategoryOptions.mixWithOthers or AVAudioSessionCategoryOptions.interruptSpokenAudioAndMixWithOthers no audio will be played (I'm using just_audio but I imagine it doesn't matter). If the session is configured with one of those two options audio will be played but media item updates will have no effect (interrupted audio from other apps will show) nor will stop/ skip commands from the media center have any effect on the audio_service. I believe this is not a bug, just iOS behavior but since this behavior is difficult to replicate in the simulator I think the documentation would benefit from an update.

Maybe a navigator prefconfiguration could also be added to the AudioSessionConfiguration.speech() and music preconfigurations.

@ryanheise
Copy link
Owner

I agree it might be helpful to add a navigator recipe and docs to audio_session, although I'm not terribly familiar with that use case myself, so I have left it to the app developer. However, I would have guessed that you wouldn't want to use audio_service (this plugin) for a navigation app on iOS. All you really need is to add the appropriate UI background mode in your Info.plist but it wouldn't make sense to display a media notification since technically you're not playing media that has a title/artist/coverart and the use case wouldn't need controls like a seek bar and so on.

@j-bbr
Copy link
Author

j-bbr commented Jan 30, 2025

Just to be clear in our case we're using the proper background mode (location) and notfications etc. can be scheduled in response to location updates in the background but the audio session can't be activated unless configured as described above.
I agree that displaying a media item is probably a fairly exotic use case but in our case we inform users of upcoming points of interest on their route with a short audio message and adding the point of interests picture and title as album art was a nice addition. What's more annoying for our use case is that the audio messages can't be skipped when played from the background, which I feel would be great even for regular navigation guidance. But since it's a system limitation as far as I understand there is no point debating it.

@ryanheise
Copy link
Owner

So there is probably nothing to be done on audio_service (this plugin), but there is potentially an issue that could be submitted for audio_session.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants