Is there a way to pause (or disable) the default music player from my Android app?

I have an application that can play sound through a mono (SCO) headset, as well as a BT stereo headset. When playing through the SCO, I use m_player.setAudioStreamTypeAudioManager.STREAM_VOICE_CALL);, and for the stereo, I use: m_player.setAudioStreamType(AudioManager.STREAM_MUSIC);. When using mono, I simply set the speech stream as a solo using: am.setStreamSolo(AudioManager.STREAM_VOICE_CALL, true);and this disables all other streams. So if there was music in the background, this does not interfere with my application. However, since the BT stereo uses a music stream, I cannot do the same, and the music continues to play simultaneously with the audio from my application.

What can I do to pause the default music app while playing my audio? I know that FroYo (2.2) and above can use requestAudioFocus (), but I need this to work on 2.0 and above, so I need a solution that does not use requestAudioFocus ().

thank

+3
source share
1 answer

If you are tied to the Android MediaPlaybackService, you can pause the main media player. here is a tutorial i found that can help you: http://www.adityatalpade.com/2010/07/31/how-to-bind-to-services-from-the-android-source/

+1
source

All Articles