4

I'm creating an app that streams audio from the web. I'd like to be able to detect connection interruptions and stuff like that. So when the audio stops playing, I'd tell the user it stopped playing. Does anyone knows a good way to do that?

Thanks!

1 Answers1

1

You are looking for MediaPlayer.setOnErrorListener() for troubles during playback and MediaPlayer.setOnCompletionListener() for receiving a callback when the sound is done playing.

Please note that the callbacks may not be on the UI thread so make sure to use runOnUiThread() when updating UI on the callbacks.

mach
  • 8,315
  • 3
  • 33
  • 51