There are a good set of intents for Android default music player which allows application to control the Player behaviour without even having to launch the Music player
Some of them are below
AudioManager mAudioManager = (AudioManager) this.getSystemService(Context.AUDIO_SERVICE);
if (mAudioManager.isMusicActive()) {
Intent musicPlayerIntent = new Intent("com.android.music.musicservicecommand");
musicPlayerIntent.putExtra("command", "pause");
sendBroadcast(musicPlayerIntent);
}
// pause
Intent i = new Intent("com.android.music.musicservicecommand");
i.putExtra("command", "pause");
sendBroadcast(i);
// play
Intent i = new Intent("com.android.music.musicservicecommand");
i.putExtra("command", "play");
sendBroadcast(i);
// next
Intent i = new Intent("com.android.music.musicservicecommand");
i.putExtra("command", "next");
sendBroadcast(i);
// previous
Intent i = new Intent("com.android.music.musicservicecommand");
i.putExtra("command", "previous");
sendBroadcast(i);
References:
No comments:
Post a Comment