2

I'd like to know if my Specific MediaPlayer instance is playing sound/music. MediaPlayer has the isPlaying method but it returns true even if the player is buffering and not playing.

Any idea how to know if MediaPlayer really plays sound?

Thanks.

Matthieu Brucher
  • 21,634
  • 7
  • 38
  • 62
AlikElzin-kilaka
  • 34,335
  • 35
  • 194
  • 277

1 Answers1

1

You can check the state of AudioPlayer by isMusicActive() method by respective method. The code snippet is as below :

AudioManager ar = (AudioManager) getSystemService(AUDIO_SERVICE);
if(ar.isMusicActive()) {
    //used
} 
Hitesh Patel
  • 2,868
  • 2
  • 33
  • 62
Report Error
  • 414
  • 2
  • 5