aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java/github/daneren2005
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2016-10-21 18:13:59 -0700
committerScott Jackson <daneren2005@gmail.com>2016-10-21 18:13:59 -0700
commitb7e728dc0788a23af2eecb9f5870c3c612aa50a7 (patch)
tree18e27510d6fa3117e9c8d3c68f3113cbde9fde0a /app/src/main/java/github/daneren2005
parent862f70536f672ff91bea830e42d4a906f8a466ae (diff)
downloaddsub-b7e728dc0788a23af2eecb9f5870c3c612aa50a7.tar.gz
dsub-b7e728dc0788a23af2eecb9f5870c3c612aa50a7.tar.bz2
dsub-b7e728dc0788a23af2eecb9f5870c3c612aa50a7.zip
Fix for Chromecast issues. Cast API appears to have changed so starting a new song triggers an additional COMPLETED broadcast while it is getting the new song ready
Diffstat (limited to 'app/src/main/java/github/daneren2005')
-rw-r--r--app/src/main/java/github/daneren2005/dsub/service/ChromeCastController.java7
1 files changed, 6 insertions, 1 deletions
diff --git a/app/src/main/java/github/daneren2005/dsub/service/ChromeCastController.java b/app/src/main/java/github/daneren2005/dsub/service/ChromeCastController.java
index 566ed773..f9e2bfb1 100644
--- a/app/src/main/java/github/daneren2005/dsub/service/ChromeCastController.java
+++ b/app/src/main/java/github/daneren2005/dsub/service/ChromeCastController.java
@@ -23,6 +23,7 @@ import android.util.Log;
import com.google.android.gms.cast.ApplicationMetadata;
import com.google.android.gms.cast.Cast;
import com.google.android.gms.cast.CastDevice;
+import com.google.android.gms.cast.CastStatusCodes;
import com.google.android.gms.cast.MediaInfo;
import com.google.android.gms.cast.MediaMetadata;
import com.google.android.gms.cast.MediaStatus;
@@ -343,6 +344,8 @@ public class ChromeCastController extends RemoteController {
public void onResult(RemoteMediaPlayer.MediaChannelResult result) {
if (result.getStatus().isSuccess()) {
// Handled in other handler
+ } else if(result.getStatus().getStatusCode() == CastStatusCodes.REPLACED) {
+ Log.w(TAG, "Request was replaced: " + currentPlaying.toString());
} else {
Log.e(TAG, "Failed to load: " + result.getStatus().toString());
failedLoad();
@@ -459,7 +462,9 @@ public class ChromeCastController extends RemoteController {
break;
case MediaStatus.PLAYER_STATE_IDLE:
if (mediaStatus.getIdleReason() == MediaStatus.IDLE_REASON_FINISHED) {
- downloadService.onSongCompleted();
+ if(downloadService.getPlayerState() != PlayerState.PREPARING) {
+ downloadService.onSongCompleted();
+ }
} else if (mediaStatus.getIdleReason() == MediaStatus.IDLE_REASON_INTERRUPTED) {
if (downloadService.getPlayerState() != PlayerState.PREPARING) {
downloadService.setPlayerState(PlayerState.PREPARING);