aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2014-02-20 06:26:25 -0800
committerScott Jackson <daneren2005@gmail.com>2014-02-20 06:26:25 -0800
commit2a20427bc07f53ace97a8a7c4ff2490e0a186e53 (patch)
tree65cd21c3824aca6739a32da08bcb1c3c9fc12c98 /src
parent7751b6fc0a9c1647ff28bce86a015c5763b56007 (diff)
downloaddsub-2a20427bc07f53ace97a8a7c4ff2490e0a186e53.tar.gz
dsub-2a20427bc07f53ace97a8a7c4ff2490e0a186e53.tar.bz2
dsub-2a20427bc07f53ace97a8a7c4ff2490e0a186e53.zip
Fix playstate showing paused while actually waiting to play still
Diffstat (limited to 'src')
-rw-r--r--src/github/daneren2005/dsub/service/ChromeCastController.java20
1 files changed, 14 insertions, 6 deletions
diff --git a/src/github/daneren2005/dsub/service/ChromeCastController.java b/src/github/daneren2005/dsub/service/ChromeCastController.java
index 0138e134..dc360797 100644
--- a/src/github/daneren2005/dsub/service/ChromeCastController.java
+++ b/src/github/daneren2005/dsub/service/ChromeCastController.java
@@ -56,6 +56,7 @@ public class ChromeCastController extends RemoteController {
private boolean applicationStarted = false;
private boolean waitingForReconnect = false;
private boolean error = false;
+ private boolean ignoreNextPaused = false;
private RemoteMediaPlayer mediaPlayer;
private double gain = 0.5;
@@ -243,15 +244,15 @@ public class ChromeCastController extends RemoteController {
.setMetadata(meta)
.build();
+ if(autoStart) {
+ ignoreNextPaused = true;
+ }
+
mediaPlayer.load(apiClient, mediaInfo, autoStart, position * 1000L).setResultCallback(new ResultCallback<RemoteMediaPlayer.MediaChannelResult>() {
@Override
public void onResult(RemoteMediaPlayer.MediaChannelResult result) {
if (result.getStatus().isSuccess()) {
- if(mediaPlayer.getMediaStatus().getPlayerState() == MediaStatus.PLAYER_STATE_PLAYING) {
- downloadService.setPlayerState(PlayerState.STARTED);
- } else {
- downloadService.setPlayerState(PlayerState.PREPARED);
- }
+ // Handled in other handler
} else if(result.getStatus().getStatusCode() != ConnectionResult.SIGN_IN_REQUIRED) {
Log.e(TAG, "Failed to load: " + result.getStatus().toString());
failedLoad();
@@ -329,10 +330,15 @@ public class ChromeCastController extends RemoteController {
MediaStatus mediaStatus = mediaPlayer.getMediaStatus();
switch(mediaStatus.getPlayerState()) {
case MediaStatus.PLAYER_STATE_PLAYING:
+ if(ignoreNextPaused) {
+ ignoreNextPaused = false;
+ }
downloadService.setPlayerState(PlayerState.STARTED);
break;
case MediaStatus.PLAYER_STATE_PAUSED:
- downloadService.setPlayerState(PlayerState.PAUSED);
+ if(!ignoreNextPaused) {
+ downloadService.setPlayerState(PlayerState.PAUSED);
+ }
break;
case MediaStatus.PLAYER_STATE_BUFFERING:
downloadService.setPlayerState(PlayerState.PREPARING);
@@ -341,6 +347,8 @@ public class ChromeCastController extends RemoteController {
if(mediaStatus.getIdleReason() == MediaStatus.IDLE_REASON_FINISHED) {
downloadService.setPlayerState(PlayerState.COMPLETED);
downloadService.next();
+ } else if(mediaStatus.getIdleReason() == MediaStatus.IDLE_REASON_INTERRUPTED) {
+ downloadService.setPlayerState(PlayerState.PREPARING);
} else {
downloadService.setPlayerState(PlayerState.IDLE);
}