Android MediaPlayer's playing state [closed]
开发者_如何学编程
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this questionI'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!
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.
精彩评论