diff options
Diffstat (limited to 'src/github')
-rw-r--r-- | src/github/daneren2005/dsub/service/DownloadService.java | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/github/daneren2005/dsub/service/DownloadService.java b/src/github/daneren2005/dsub/service/DownloadService.java index 9c7cb459..7cf76e4f 100644 --- a/src/github/daneren2005/dsub/service/DownloadService.java +++ b/src/github/daneren2005/dsub/service/DownloadService.java @@ -1186,7 +1186,7 @@ public class DownloadService extends Service { } if(routeId != null) { - handler.post(new Runnable() { + final Runnable delayedReconnect = new Runnable() { @Override public void run() { RouteInfo info = mediaRouter.getRouteForId(routeId); @@ -1198,6 +1198,23 @@ public class DownloadService extends Service { setRemoteState(RemoteControlState.CHROMECAST, controller); } } + mediaRouter.stopScan(); + } + }; + + handler.post(new Runnable() { + @Override + public void run() { + mediaRouter.startScan(); + RouteInfo info = mediaRouter.getRouteForId(routeId); + if(info == null) { + handler.postDelayed(delayedReconnect, 2000L); + } else if(newState == RemoteControlState.CHROMECAST) { + RemoteController controller = mediaRouter.getRemoteController(info); + if(controller != null) { + setRemoteState(RemoteControlState.CHROMECAST, controller); + } + } } }); } |