aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2014-03-15 21:20:02 -0700
committerScott Jackson <daneren2005@gmail.com>2014-03-15 21:20:02 -0700
commit6d2a136e2bac824b7151d71f9583efbc03f622e2 (patch)
treec0aa0954c0c58cc5e81b1ab02908fa0049e36378 /src
parent34edf50d1b016bb5cd437195ed76336f66a4c83e (diff)
downloaddsub-6d2a136e2bac824b7151d71f9583efbc03f622e2.tar.gz
dsub-6d2a136e2bac824b7151d71f9583efbc03f622e2.tar.bz2
dsub-6d2a136e2bac824b7151d71f9583efbc03f622e2.zip
Add getDuration fallback for remoteControllers
Diffstat (limited to 'src')
-rw-r--r--src/github/daneren2005/dsub/service/ChromeCastController.java11
-rw-r--r--src/github/daneren2005/dsub/service/DownloadService.java12
-rw-r--r--src/github/daneren2005/dsub/service/RemoteController.java3
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;