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.
发布评论
评论(1)
您正在寻找 MediaPlayer.setOnErrorListener() 来解决播放期间的问题,并寻找 MediaPlayer.setOnCompletionListener() 来在声音播放完毕时接收回调。
请注意,回调可能不在 UI 线程上,因此请确保在回调上更新 UI 时使用 runOnUiThread()。
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.