Skip to content

Commit

Permalink
Fix possible multiple skips.
Browse files Browse the repository at this point in the history
  • Loading branch information
arturdryomov committed Jul 11, 2014
1 parent b6cbd42 commit ea5bd17
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/main/java/org/amahi/anywhere/service/AudioService.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -119,6 +120,7 @@ private void setUpAudioPlayer() {
audioPlayer.setWakeMode(this, PowerManager.PARTIAL_WAKE_LOCK);

audioPlayer.setOnCompletionListener(this);
audioPlayer.setOnErrorListener(this);
}

private void setUpAudioPlayerRemote() {
Expand Down Expand Up @@ -170,9 +172,9 @@ private Uri getAudioUri() {

@Override
public void onPrepared(MediaPlayer audioPlayer) {
playAudio();

BusProvider.getBus().post(new AudioPreparedEvent());

playAudio();
}

private void setUpAudioMetadata() {
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit ea5bd17

Please sign in to comment.