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:
I want to pause and resume the music of the default music player from my application.
Is it possible to do this?
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);
}