-
-
Notifications
You must be signed in to change notification settings - Fork 51
Description
Description
When using flutter_soloud together with audio_session, background audio (like Spotify) gets ducked continuously after activating the session, even when no sound is playing. I want to play short sounds occasionally and have other audio duck only during playback, similar to how apps like Strava or Google Maps behave.
Steps To Reproduce
- Play audio in other app (e.g. Spotify)
- Set up audio_session with
AudioSessionConfiguration(
androidWillPauseWhenDucked: true,
androidAudioAttributes: AndroidAudioAttributes(
usage: AndroidAudioUsage.assistanceNavigationGuidance,
contentType: AndroidAudioContentType.speech,
),
androidAudioFocusGainType:
AndroidAudioFocusGainType.gainTransientMayDuck,
avAudioSessionCategory: AVAudioSessionCategory.playback,
avAudioSessionCategoryOptions: AVAudioSessionCategoryOptions.duckOthers,
avAudioSessionMode: AVAudioSessionMode.spokenAudio,
)
- Observe that background audio is ducked on app startup
- Activate the session with setActive(true)
- Play a sound using flutter_soloud
- Observe that background audio remains ducked even after playback ends
Expected Behavior
Background audio should duck only during playback and return to normal once the sound finishes.
Additional Context
Tested on iOS with both flutter_soloud 3.3.4 and 3.1.12 (before audio_session support was introduced). I followed the example from audio_context.dart while changing the configuration. The goal is to play occasional sounds while respecting other audio sources.
I haven't tested the later versions of flutter_soloud on Android yet. I recall not having this issue there, but this presumably was before v3.2.1. That may or may not mean that behaviour differs depending on the device (or my configuration differs). Though I do not have an Android device to test this.