-
Notifications
You must be signed in to change notification settings - Fork 628
Open
Labels
Description
Use case description
I’m developing an app that plays audio for users in a museum (like a virtual tour guide). The app needs to detect the current audio output device so it can automatically adjust the maximum volume. Specifically:
- Speaker mode: If the user is listening through the phone’s built-in speaker, the app lowers the volume (similar to a voice call), so it doesn’t disturb other visitors.
- Headphones (wired or wireless): The volume can be restored to normal or maximum.
Proposed solution
Add an API that allows apps to listen to changes of current audio output (e.g., speaker ↔ headphones ↔ Bluetooth).
This would enable apps to accurately respond in real time and adjust their audio behavior accordingly.
Users can change it here:
Alternatives considered
- Manually detecting routing changes with current Android APIs (e.g.,
AudioManager
,AudioDeviceCallback
,MediaRouter
or silentAudioTrack
withAudioRouting
) has proven unreliable or inconsistent when the user switches audio outputs manually without disconnecting headphones. AudioBecomingNoisy
doesn't trigger when the user switches audio outputs manually and works only in one direction (from headphones to speaker).- Using
C.USAGE_VOICE_COMMUNICATION
can mimic call-like audio, but it causes problems:- Google Assistant can’t stop playback while listening for voice.
- Incoming/outgoing phone calls may not automatically pause the playback.
- Other media apps might fail to stop or duck this playback.
Given these limitations, an official, reliable listener/callback for audio output routing changes in Media3/ExoPlayer would greatly simplify the development of apps with dynamic audio output requirements.