diff options
author | Scott Jackson <daneren2005@gmail.com> | 2015-09-18 09:04:15 -0700 |
---|---|---|
committer | Scott Jackson <daneren2005@gmail.com> | 2015-09-18 09:04:15 -0700 |
commit | 3f97c4c2be24ceeea1d9ca067950820f1d2896d8 (patch) | |
tree | 56d81c8a0a93eb16a78d7d303ccebbe87cc72c8f /app/src/main/java/github | |
parent | d763831ecf000f0dc3667171d8448e2780718794 (diff) | |
download | dsub-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/src/main/java/github')
-rw-r--r-- | app/src/main/java/github/daneren2005/dsub/service/DownloadService.java | 34 |
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; |