aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2014-11-20 15:28:37 -0800
committerScott Jackson <daneren2005@gmail.com>2014-11-20 15:28:37 -0800
commit3c95288c04dbf79bcd27f8b3515c23013876f48e (patch)
tree428517abe7c1238ddfbc99e304f03dde553bf0a6 /src
parent44ab1332de5c669848dfa78ba095f5d3f2f69c16 (diff)
downloaddsub-3c95288c04dbf79bcd27f8b3515c23013876f48e.tar.gz
dsub-3c95288c04dbf79bcd27f8b3515c23013876f48e.tar.bz2
dsub-3c95288c04dbf79bcd27f8b3515c23013876f48e.zip
L on Nexus 5 jump position later instead of immediately like KK
Diffstat (limited to 'src')
-rw-r--r--src/github/daneren2005/dsub/service/DownloadService.java17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/github/daneren2005/dsub/service/DownloadService.java b/src/github/daneren2005/dsub/service/DownloadService.java
index 691a32b2..cee2c456 100644
--- a/src/github/daneren2005/dsub/service/DownloadService.java
+++ b/src/github/daneren2005/dsub/service/DownloadService.java
@@ -1187,7 +1187,16 @@ public class DownloadService extends Service {
while(isRunning) {
try {
if(mediaPlayer != null && playerState == STARTED) {
- cachedPosition = mediaPlayer.getCurrentPosition();
+ int newPosition = mediaPlayer.getCurrentPosition();
+
+ // If sudden jump in position, something is wrong
+ if(subtractNextPosition == 0 && newPosition > (cachedPosition + 5000)) {
+ // Only 1 second should have gone by, subtract the rest
+ subtractPosition += (newPosition - cachedPosition) - 1000;
+ }
+
+ cachedPosition = newPosition;
+
if(subtractNextPosition > 0) {
// Subtraction amount is current position - how long ago onCompletionListener was called
subtractPosition = cachedPosition - (int) (System.currentTimeMillis() - subtractNextPosition);
@@ -1226,7 +1235,7 @@ public class DownloadService extends Service {
public void setSuggestedPlaylistName(String name, String id) {
this.suggestedPlaylistName = name;
this.suggestedPlaylistId = id;
-
+
SharedPreferences.Editor editor = Util.getPreferences(this).edit();
editor.putString(Constants.PREFERENCES_KEY_PLAYLIST_NAME, name);
editor.putString(Constants.PREFERENCES_KEY_PLAYLIST_ID, id);
@@ -1276,7 +1285,7 @@ public class DownloadService extends Service {
// Don't try again, just resetup media player and continue on
controller = null;
}
-
+
// Restart from same position and state we left off in
play(getCurrentPlayingIndex(), false, pos);
}
@@ -1505,7 +1514,7 @@ public class DownloadService extends Service {
if (start || autoPlayStart) {
mediaPlayer.start();
setPlayerState(STARTED);
-
+
// Disable autoPlayStart after done
autoPlayStart = false;
} else {