From 2b11caece9c49406099fc192fda4215171ef0f58 Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Fri, 11 Jul 2014 19:48:57 -0700 Subject: Fix issue with going to repeat song mode not removing nextPlaying setup --- .../daneren2005/dsub/service/DownloadService.java | 24 +++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/src/github/daneren2005/dsub/service/DownloadService.java b/src/github/daneren2005/dsub/service/DownloadService.java index 901d0578..44c22009 100644 --- a/src/github/daneren2005/dsub/service/DownloadService.java +++ b/src/github/daneren2005/dsub/service/DownloadService.java @@ -700,6 +700,7 @@ public class DownloadService extends Service { nextPlayingTask = new CheckCompletionTask(nextPlaying); nextPlayingTask.execute(); } else { + resetNext(); nextPlaying = null; } } @@ -996,6 +997,21 @@ public class DownloadService extends Service { } } + public synchronized void resetNext() { + if(nextMediaPlayer != null) { + if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { + mediaPlayer.setNextMediaPlayer(null); + nextSetup = false; + } + + nextMediaPlayer.setOnCompletionListener(null); + nextMediaPlayer.setOnErrorListener(null); + nextMediaPlayer.reset(); + nextMediaPlayer.release(); + nextMediaPlayer = null; + } + } + public int getPlayerPosition() { try { if (playerState == IDLE || playerState == DOWNLOADING || playerState == PREPARING) { @@ -1397,13 +1413,7 @@ public class DownloadService extends Service { private synchronized void setupNext(final DownloadFile downloadFile) { try { final File file = downloadFile.isCompleteFileAvailable() ? downloadFile.getCompleteFile() : downloadFile.getPartialFile(); - if(nextMediaPlayer != null) { - nextMediaPlayer.setOnCompletionListener(null); - nextMediaPlayer.setOnErrorListener(null); - nextMediaPlayer.reset(); - nextMediaPlayer.release(); - nextMediaPlayer = null; - } + resetNext(); // Exit when using remote controllers if(remoteState != RemoteControlState.LOCAL) { -- cgit v1.2.3