开发者

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

I have an app that has the capability to play audio through a mono (SCO) headset as well as a Stereo BT headset. When playing through SCO, I use m_player.setAudioStreamTypeAudioManager.STREAM_VOICE_CALL);, and for stereo, I use:m_player.setAudioStreamType(AudioManager.STREAM_MUSIC);. When using mono, I just set the voice stream as solo using: am.setStreamSolo(AudioManager.STREAM_VOICE_CALL, true);, and that mutes all other streams. So that if there was music playing in the background, it doesn't interfere with my app. However, since the stereo BT uses the music stream, I can't do the same thing, and the music keeps playing at the same time as the audio from my app.

What can I do to pause the default music app while my audio is playing? I know FroYo (开发者_如何转开发2.2) and higher can use requestAudioFocus(), but I need to have this work on 2.0 and up, so I need a solution that doesn't use requestAudioFocus().

Thanks


If you bind to the android MediaPlaybackService you should be able to pause the main media player. here is a tutorial that i found that may help you: http://www.adityatalpade.com/2010/07/31/how-to-bind-to-services-from-the-android-source/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜