aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java/github/daneren2005
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2016-02-11 22:17:04 -0800
committerScott Jackson <daneren2005@gmail.com>2016-02-11 22:17:04 -0800
commit39c7f5b302d20c24e274850e5f9c63a5df714c07 (patch)
treed7a4c0b090ef0a629cfb2a56c28f80de7ceefec7 /app/src/main/java/github/daneren2005
parenta3462662094fe068fee91a759c1d54d367d6dc6f (diff)
downloaddsub-39c7f5b302d20c24e274850e5f9c63a5df714c07.tar.gz
dsub-39c7f5b302d20c24e274850e5f9c63a5df714c07.tar.bz2
dsub-39c7f5b302d20c24e274850e5f9c63a5df714c07.zip
Fix clicking play while casting not starting automatically
Diffstat (limited to 'app/src/main/java/github/daneren2005')
-rw-r--r--app/src/main/java/github/daneren2005/dsub/service/ChromeCastController.java28
1 files changed, 25 insertions, 3 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 bc54f486..c2007139 100644
--- a/app/src/main/java/github/daneren2005/dsub/service/ChromeCastController.java
+++ b/app/src/main/java/github/daneren2005/dsub/service/ChromeCastController.java
@@ -62,6 +62,8 @@ public class ChromeCastController extends RemoteController {
private boolean error = false;
private boolean ignoreNextPaused = false;
private String sessionId;
+ private boolean isStopping = false;
+ private Runnable afterUpdateComplete = null;
private ServerProxy proxy;
private String rootLocation;
@@ -247,18 +249,38 @@ public class ChromeCastController extends RemoteController {
}
}
- void startSong(DownloadFile currentPlaying, boolean autoStart, int position) {
+ void startSong(final DownloadFile currentPlaying, final boolean autoStart, final int position) {
if(currentPlaying == null) {
try {
- if (mediaPlayer != null && !error) {
- mediaPlayer.stop(apiClient);
+ if (mediaPlayer != null && !error && !isStopping) {
+ isStopping = true;
+ mediaPlayer.stop(apiClient).setResultCallback(new ResultCallback<RemoteMediaPlayer.MediaChannelResult>() {
+ @Override
+ public void onResult(RemoteMediaPlayer.MediaChannelResult mediaChannelResult) {
+ isStopping = false;
+
+ if(afterUpdateComplete != null) {
+ afterUpdateComplete.run();
+ afterUpdateComplete = null;
+ }
+ }
+ });
}
} catch(Exception e) {
// Just means it didn't need to be stopped
}
downloadService.setPlayerState(PlayerState.IDLE);
return;
+ } else if(isStopping) {
+ afterUpdateComplete = new Runnable() {
+ @Override
+ public void run() {
+ startSong(currentPlaying, autoStart, position);
+ }
+ };
+ return;
}
+
downloadService.setPlayerState(PlayerState.PREPARING);
MusicDirectory.Entry song = currentPlaying.getSong();