通过AudioManager的isMusicActive(),可以判断当前是否有音乐正在播放。
/**
* AudioManager provides access to volume and ringer mode control.
*
* Use Context.getSystemService(Context.AUDIO_SERVICE) to get
* an instance of this class.
*/
public class AudioManager {
...
/**
* Checks whether any music is active.
*
* @return true if any music tracks are active.
*/
public boolean isMusicActive() {
return AudioSystem.isStreamActive(STREAM_MUSIC, 0);
}
...
}
看看任务管理器,播放器有没有在后台运行