diff options
3 files changed, 21 insertions, 5 deletions
diff --git a/src/github/daneren2005/dsub/service/ChromeCastController.java b/src/github/daneren2005/dsub/service/ChromeCastController.java index a7c8798a..5a989fca 100644 --- a/src/github/daneren2005/dsub/service/ChromeCastController.java +++ b/src/github/daneren2005/dsub/service/ChromeCastController.java @@ -86,7 +86,7 @@ public class ChromeCastController extends RemoteController { @Override public void onApplicationStatusChanged() { if (apiClient != null) { - Log.d(TAG, "onApplicationStatusChanged: " + Cast.CastApi.getApplicationStatus(apiClient)); + Log.i(TAG, "onApplicationStatusChanged: " + Cast.CastApi.getApplicationStatus(apiClient)); } } @@ -221,6 +221,15 @@ public class ChromeCastController extends RemoteController { } } + @Override + public int getRemoteDuration() { + if(mediaPlayer != null) { + return (int) (mediaPlayer.getStreamDuration() / 1000L); + } else { + return 0; + } + } + void startSong(DownloadFile currentPlaying, boolean autoStart, int position) { if(currentPlaying == null) { try { diff --git a/src/github/daneren2005/dsub/service/DownloadService.java b/src/github/daneren2005/dsub/service/DownloadService.java index fbfdd50d..a846c1a7 100644 --- a/src/github/daneren2005/dsub/service/DownloadService.java +++ b/src/github/daneren2005/dsub/service/DownloadService.java @@ -956,10 +956,14 @@ public class DownloadService extends Service { } } if (playerState != IDLE && playerState != DOWNLOADING && playerState != PlayerState.PREPARING) { - try { - return mediaPlayer.getDuration(); - } catch (Exception x) { - handleError(x); + if(remoteState == RemoteControlState.LOCAL) { + try { + return mediaPlayer.getDuration(); + } catch (Exception x) { + handleError(x); + } + } else { + return remoteController.getRemoteDuration() * 1000; } } return 0; diff --git a/src/github/daneren2005/dsub/service/RemoteController.java b/src/github/daneren2005/dsub/service/RemoteController.java index 17deec27..e41a37ad 100644 --- a/src/github/daneren2005/dsub/service/RemoteController.java +++ b/src/github/daneren2005/dsub/service/RemoteController.java @@ -49,6 +49,9 @@ public abstract class RemoteController { public abstract void setVolume(boolean up); public abstract int getRemotePosition(); + public int getRemoteDuration() { + return 0; + } protected abstract class RemoteTask { abstract RemoteStatus execute() throws Exception; |