I want to write a program which can pause and play every media players in android. How can i set priority of this program higher than the others? also i wrote the following code
public static final String SERVICECMD = "com.android.music.musicservicecommand";
public static final String CMDNAME = "command";
public static final String CMDPAUSE = "pause";
public static final String CMDPLAY = "play";
public static final String CMDTOGGLEPAUSE = "togglepause";
AudioManager mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
if (mAudioManager.isMusicActive()) {
Intent i = new Intent(SERVICECMD);
i.putExtra(CMDNAME, CMDPAUSE);
MainActivity.this.sendBroadcast(i);
Toast.makeText(this, "media player is pause!", Toast.LENGTH_LONG).show();
}
if (!mAudioManager.isMusicActive()) {
Intent i = new Intent(SERVICECMD);
i.putExtra(CMDNAME, CMDPLAY);
MainActivity.this.sendBroadcast(i);
Toast.makeText(this, "media player is play!", Toast.LENGTH_LONG).show();
}
and it can pause every players but i dont know how to play them again. I can play some players but not all of them i dont know why ???