aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2015-09-18 09:04:15 -0700
committerScott Jackson <daneren2005@gmail.com>2015-09-18 09:04:15 -0700
commit3f97c4c2be24ceeea1d9ca067950820f1d2896d8 (patch)
tree56d81c8a0a93eb16a78d7d303ccebbe87cc72c8f /app
parentd763831ecf000f0dc3667171d8448e2780718794 (diff)
downloaddsub-3f97c4c2be24ceeea1d9ca067950820f1d2896d8.tar.gz
dsub-3f97c4c2be24ceeea1d9ca067950820f1d2896d8.tar.bz2
dsub-3f97c4c2be24ceeea1d9ca067950820f1d2896d8.zip
Pull duration from media player first, fix position/duration not updating during buffering
Diffstat (limited to 'app')
-rw-r--r--app/src/main/java/github/daneren2005/dsub/service/DownloadService.java34
1 files changed, 22 insertions, 12 deletions
diff --git a/app/src/main/java/github/daneren2005/dsub/service/DownloadService.java b/app/src/main/java/github/daneren2005/dsub/service/DownloadService.java
index a828ae4a..d69bf431 100644
--- a/app/src/main/java/github/daneren2005/dsub/service/DownloadService.java
+++ b/app/src/main/java/github/daneren2005/dsub/service/DownloadService.java
@@ -1249,23 +1249,30 @@ public class DownloadService extends Service {
}
public synchronized int getPlayerDuration() {
- if (currentPlaying != null) {
- Integer duration = currentPlaying.getSong().getDuration();
- if (duration != null) {
- return duration * 1000;
- }
- }
if (playerState != IDLE && playerState != DOWNLOADING && playerState != PlayerState.PREPARING) {
+ int duration = 0;
if(remoteState == LOCAL) {
try {
- return mediaPlayer.getDuration();
+ duration = mediaPlayer.getDuration();
} catch (Exception x) {
- handleError(x);
+ duration = 0;
}
} else {
- return remoteController.getRemoteDuration() * 1000;
+ duration = remoteController.getRemoteDuration() * 1000;
+ }
+
+ if(duration != 0) {
+ return duration;
+ }
+ }
+
+ if (currentPlaying != null) {
+ Integer duration = currentPlaying.getSong().getDuration();
+ if (duration != null) {
+ return duration * 1000;
}
}
+
return 0;
}
@@ -2475,9 +2482,12 @@ public class DownloadService extends Service {
});
}
- if(playerState != STARTED) {
- onSongProgress();
- }
+ mediaPlayerHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ onSongProgress();
+ }
+ });
}
private void onSongsChanged() {
final long atRevision = revision;