aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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;