aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2013-06-09 18:30:35 -0700
committerScott Jackson <daneren2005@gmail.com>2013-06-09 18:30:35 -0700
commit41a0bdc592bd9d81efc958f59db57e0ce7498a5f (patch)
tree550ca0d60992553ab9cea96b7944e0ad5144045c
parentc2dfbf3d114fc7e38950e508aab28970be83d8de (diff)
downloaddsub-41a0bdc592bd9d81efc958f59db57e0ce7498a5f.tar.gz
dsub-41a0bdc592bd9d81efc958f59db57e0ce7498a5f.tar.bz2
dsub-41a0bdc592bd9d81efc958f59db57e0ce7498a5f.zip
On error, skip to next if within 10 seconds of the end like completion handler
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceImpl.java36
1 files changed, 21 insertions, 15 deletions
diff --git a/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceImpl.java b/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceImpl.java
index 7858ac3a..664754b1 100644
--- a/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceImpl.java
+++ b/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceImpl.java
@@ -648,7 +648,18 @@ public class DownloadServiceImpl extends Service implements DownloadService {
setNextPlaying();
}
}
-
+ private synchronized void playNext() {
+ if(nextPlaying != null && nextPlayerState == PlayerState.PREPARED) {
+ if(!nextSetup) {
+ playNext(true);
+ } else {
+ nextSetup = false;
+ playNext(false);
+ }
+ } else {
+ onSongCompleted();
+ }
+ }
private synchronized void playNext(boolean start) {
// Swap the media players since nextMediaPlayer is ready to play
if(start) {
@@ -1135,19 +1146,23 @@ public class DownloadServiceImpl extends Service implements DownloadService {
}
private void setupHandlers(final DownloadFile downloadFile, final boolean isPartial) {
+ final int duration = downloadFile.getSong().getDuration() == null ? 0 : downloadFile.getSong().getDuration() * 1000;
mediaPlayer.setOnErrorListener(new MediaPlayer.OnErrorListener() {
public boolean onError(MediaPlayer mediaPlayer, int what, int extra) {
Log.w(TAG, "Error on playing file " + "(" + what + ", " + extra + "): " + downloadFile);
int pos = cachedPosition;
reset();
- downloadFile.setPlaying(false);
- doPlay(downloadFile, pos, true);
- downloadFile.setPlaying(true);
+ if (!isPartial || (downloadFile.isWorkDone() && (Math.abs(duration - pos) < 10000))) {
+ playNext();
+ } else {
+ downloadFile.setPlaying(false);
+ doPlay(downloadFile, pos, true);
+ downloadFile.setPlaying(true);
+ }
return true;
}
});
- final int duration = downloadFile.getSong().getDuration() == null ? 0 : downloadFile.getSong().getDuration() * 1000;
mediaPlayer.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
@Override
public void onCompletion(MediaPlayer mediaPlayer) {
@@ -1161,16 +1176,7 @@ public class DownloadServiceImpl extends Service implements DownloadService {
int pos = cachedPosition;
Log.i(TAG, "Ending position " + pos + " of " + duration);
if (!isPartial || (downloadFile.isWorkDone() && (Math.abs(duration - pos) < 10000))) {
- if(nextPlaying != null && nextPlayerState == PlayerState.PREPARED) {
- if(!nextSetup) {
- playNext(true);
- } else {
- nextSetup = false;
- playNext(false);
- }
- } else {
- onSongCompleted();
- }
+ playNext();
return;
}