diff --git a/src/main/java/org/amahi/anywhere/service/AudioService.java b/src/main/java/org/amahi/anywhere/service/AudioService.java index 98bec6681..97bb1a004 100644 --- a/src/main/java/org/amahi/anywhere/service/AudioService.java +++ b/src/main/java/org/amahi/anywhere/service/AudioService.java @@ -64,7 +64,8 @@ public class AudioService extends Service implements AudioManager.OnAudioFocusChangeListener, MediaPlayer.OnPreparedListener, - MediaPlayer.OnCompletionListener + MediaPlayer.OnCompletionListener, + MediaPlayer.OnErrorListener { private static final class Notifications { @@ -119,6 +120,7 @@ private void setUpAudioPlayer() { audioPlayer.setWakeMode(this, PowerManager.PARTIAL_WAKE_LOCK); audioPlayer.setOnCompletionListener(this); + audioPlayer.setOnErrorListener(this); } private void setUpAudioPlayerRemote() { @@ -170,9 +172,9 @@ private Uri getAudioUri() { @Override public void onPrepared(MediaPlayer audioPlayer) { - playAudio(); - BusProvider.getBus().post(new AudioPreparedEvent()); + + playAudio(); } private void setUpAudioMetadata() { @@ -388,9 +390,14 @@ private void tearDownAudioVolume() { @Override public void onCompletion(MediaPlayer audioPlayer) { + BusProvider.getBus().post(new AudioCompletedEvent()); + startNextAudio(); + } - BusProvider.getBus().post(new AudioCompletedEvent()); + @Override + public boolean onError(MediaPlayer audioPlayer, int errorReason, int errorExtra) { + return true; } @Override