From 32fd7c300851ebd558cd17a7d5c90f8cf7f17530 Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Mon, 30 Nov 2015 17:19:15 -0800 Subject: #589 Fix case where we are trying to setup the next song before the current one is actually playing --- .../java/github/daneren2005/dsub/service/DLNAController.java | 2 +- .../java/github/daneren2005/dsub/service/DownloadService.java | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) (limited to 'app/src/main/java') diff --git a/app/src/main/java/github/daneren2005/dsub/service/DLNAController.java b/app/src/main/java/github/daneren2005/dsub/service/DLNAController.java index a0dc16c1..94bf7231 100644 --- a/app/src/main/java/github/daneren2005/dsub/service/DLNAController.java +++ b/app/src/main/java/github/daneren2005/dsub/service/DLNAController.java @@ -633,7 +633,7 @@ public class DLNAController extends RemoteController { if(positionInfo.getTrackURI() != null && positionInfo.getTrackURI().equals(nextPlayingURI) && downloadService.getNextPlayerState() == PlayerState.PREPARED) { downloadService.setCurrentPlaying(nextPlaying, true); downloadService.setPlayerState(PlayerState.STARTED); - downloadService.setNextPlaying(); + downloadService.setNextPlayerState(PlayerState.IDLE); } downloadService.postDelayed(new Runnable() { diff --git a/app/src/main/java/github/daneren2005/dsub/service/DownloadService.java b/app/src/main/java/github/daneren2005/dsub/service/DownloadService.java index 37070903..ae619802 100644 --- a/app/src/main/java/github/daneren2005/dsub/service/DownloadService.java +++ b/app/src/main/java/github/daneren2005/dsub/service/DownloadService.java @@ -1416,9 +1416,7 @@ public class DownloadService extends Service { } if(remoteController != null && remoteController.isNextSupported()) { - if(playerState == STARTED && nextPlayerState == IDLE) { - setNextPlaying(); - } else if(playerState == PREPARING || playerState == IDLE) { + if(playerState == PREPARING || playerState == IDLE) { nextPlayerState = IDLE; } } @@ -2679,6 +2677,13 @@ public class DownloadService extends Service { } }); } + + // Setup next playing at least a couple of seconds into the song since both Chromecast and some DLNA clients report PLAYING when still PREPARING + if(position > 2000 && remoteController != null && remoteController.isNextSupported()) { + if(playerState == STARTED && nextPlayerState == IDLE) { + setNextPlaying(); + } + } } private void onStateUpdate() { final long atRevision = revision; -- cgit v1.2.3