由网友(青春,奋斗吧)分享简介:在我的Android应用程序,我玩用的MediaPlayer类不同的MP3文件。In my Android application, I am playing different mp3 files using the MediaPlayer class.该用户正在播放的他/她自己的音乐与默认的音乐应用程序。...
在我的Android应用程序,我玩用的MediaPlayer类不同的MP3文件。
In my Android application, I am playing different mp3 files using the MediaPlayer class.
该用户正在播放的他/她自己的音乐与默认的音乐应用程序。
The user is playing his/her own music with the default music application.
我想:
暂停默认的音乐应用程序的音乐。 开始从我的应用程序播放音乐。 如果我的音乐是做打,我的应用程序将恢复用户的默认音乐。我想停下来,从我的应用程序恢复默认的音乐播放器的音乐。
I want to pause and resume the music of the default music player from my application.
是否有可能这样做吗?
推荐答案
以下code将暂停一个默认的MediaPlayer通过发送一个广播:
The following code will pause a default MediaPlayer by sending a broadcast:
AudioManager mAudioManager = (AudioManager) this.getSystemService(Context.AUDIO_SERVICE);
if (mAudioManager.isMusicActive()) {
Intent i = new Intent("com.android.music.musicservicecommand");
i.putExtra("command", "pause");
YourApplicationClass.this.sendBroadcast(i);
}
相关推荐
最新文章