1

I want to detect the stop event of android music player.
I am actually calling a method when the file stops playing.
There is an isPlaying method, but in order to get the stop event, I need to put it inside a while loop which might induce instability?
Is there an elegant way to do this?
This is the code I have:

mp.start(); // mp is the media player object
while (mp.isPlaying() == true) continue;
handler.sendEmptyMessage(0);


Thank you.

Brahadeesh
  • 2,245
  • 8
  • 40
  • 58

1 Answers1

3

MediaPlayer has an OnCompletionListener callback you can register to get notified when playback stops.

mportuesisf
  • 5,587
  • 2
  • 33
  • 26