aboutsummaryrefslogtreecommitdiff
path: root/subsonic-android/src/github
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2012-12-05 22:03:17 -0800
committerScott Jackson <daneren2005@gmail.com>2012-12-05 22:03:17 -0800
commit896a36011f4976f8caab058d02b66768306ba2e7 (patch)
tree8a62c241bdc76553e6e104815b47f8b91982dbdb /subsonic-android/src/github
parent6736055d0175b86382b5c7c47a26c694acea0670 (diff)
downloaddsub-896a36011f4976f8caab058d02b66768306ba2e7.tar.gz
dsub-896a36011f4976f8caab058d02b66768306ba2e7.tar.bz2
dsub-896a36011f4976f8caab058d02b66768306ba2e7.zip
Fix for complete broken in previous commit + possible fix for restart from beginning issue
Diffstat (limited to 'subsonic-android/src/github')
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceImpl.java14
1 files changed, 10 insertions, 4 deletions
diff --git a/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceImpl.java b/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceImpl.java
index 0a04394a..90aec2b7 100644
--- a/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceImpl.java
+++ b/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceImpl.java
@@ -101,6 +101,7 @@ public class DownloadServiceImpl extends Service implements DownloadService {
private String suggestedPlaylistName;
private PowerManager.WakeLock wakeLock;
private boolean keepScreenOn;
+ private int cachedPosition = 0;
private static boolean equalizerAvailable;
private static boolean visualizerAvailable;
@@ -681,9 +682,11 @@ public class DownloadServiceImpl extends Service implements DownloadService {
return 0;
}
if (jukeboxEnabled) {
- return jukeboxService.getPositionSeconds() * 1000;
+ cachedPosition = jukeboxService.getPositionSeconds() * 1000;
+ return cachedPosition;
} else {
- return mediaPlayer.getCurrentPosition();
+ cachedPosition = mediaPlayer.getCurrentPosition();
+ return cachedPosition;
}
} catch (Exception x) {
handleError(x);
@@ -820,12 +823,16 @@ public class DownloadServiceImpl extends Service implements DownloadService {
// If COMPLETED and file is completely cached
if (downloadFile.isWorkDone()) {
onSongCompleted();
+ return;
}
// If file is not completely downloaded, restart the playback from the current position.
int pos = mediaPlayer.getCurrentPosition();
+ if(pos == 0) {
+ Log.w(TAG, "Using cached current position");
+ pos = cachedPosition;
+ }
synchronized (DownloadServiceImpl.this) {
-
// Work-around for apparent bug on certain phones: If close (less than ten seconds) to the end
// of the song, skip to the next rather than restarting it.
Integer duration = downloadFile.getSong().getDuration() == null ? null : downloadFile.getSong().getDuration() * 1000;
@@ -837,7 +844,6 @@ public class DownloadServiceImpl extends Service implements DownloadService {
}
}
- // 12-04 18:59:19.350 I/DownloadServiceImpl( 2761): Requesting restart from 0 of 261000
Log.i(TAG, "Requesting restart from " + pos + " of " + duration);
reset();
bufferTask = new BufferTask(downloadFile, pos);