From 9efb112d3dcf0ce8a9419daa050c29e17fe824ad Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Tue, 25 Mar 2014 19:56:00 -0700 Subject: Check for play services, fix cast showing up when cast_available = false --- .../daneren2005/dsub/provider/JukeboxRouteProvider.java | 6 +++--- src/github/daneren2005/dsub/util/MediaRouteManager.java | 14 +++++++++++++- 2 files changed, 16 insertions(+), 4 deletions(-) (limited to 'src/github/daneren2005') diff --git a/src/github/daneren2005/dsub/provider/JukeboxRouteProvider.java b/src/github/daneren2005/dsub/provider/JukeboxRouteProvider.java index eaefbf55..da6e0c2c 100644 --- a/src/github/daneren2005/dsub/provider/JukeboxRouteProvider.java +++ b/src/github/daneren2005/dsub/provider/JukeboxRouteProvider.java @@ -35,7 +35,7 @@ import github.daneren2005.dsub.service.DownloadService; * Created by Scott on 11/28/13. */ public class JukeboxRouteProvider extends MediaRouteProvider { - public static final String CATEGORY_SAMPLE_ROUTE = "github.daneren2005.dsub.SERVER_JUKEBOX"; + public static final String CATEGORY_JUKEBOX_ROUTE = "github.daneren2005.dsub.SERVER_JUKEBOX"; private static int MAX_VOLUME = 10; private DownloadService downloadService; @@ -46,7 +46,7 @@ public class JukeboxRouteProvider extends MediaRouteProvider { // Create intents IntentFilter routeIntentFilter = new IntentFilter(); - routeIntentFilter.addCategory(MediaControlIntent.CATEGORY_REMOTE_PLAYBACK); + routeIntentFilter.addCategory(CATEGORY_JUKEBOX_ROUTE); routeIntentFilter.addAction(MediaControlIntent.ACTION_START_SESSION); routeIntentFilter.addAction(MediaControlIntent.ACTION_GET_SESSION_STATUS); routeIntentFilter.addAction(MediaControlIntent.ACTION_END_SESSION); @@ -81,7 +81,7 @@ public class JukeboxRouteProvider extends MediaRouteProvider { @Override public boolean onControlRequest(Intent intent, android.support.v7.media.MediaRouter.ControlRequestCallback callback) { - if (intent.hasCategory(MediaControlIntent.CATEGORY_REMOTE_PLAYBACK)) { + if (intent.hasCategory(CATEGORY_JUKEBOX_ROUTE)) { return true; } else { return false; diff --git a/src/github/daneren2005/dsub/util/MediaRouteManager.java b/src/github/daneren2005/dsub/util/MediaRouteManager.java index 95cded67..9b4110f3 100644 --- a/src/github/daneren2005/dsub/util/MediaRouteManager.java +++ b/src/github/daneren2005/dsub/util/MediaRouteManager.java @@ -19,6 +19,10 @@ import android.support.v7.media.MediaControlIntent; import android.support.v7.media.MediaRouteProvider; import android.support.v7.media.MediaRouteSelector; import android.support.v7.media.MediaRouter; +import android.util.Log; + +import com.google.android.gms.common.ConnectionResult; +import com.google.android.gms.common.GooglePlayServicesUtil; import java.util.ArrayList; import java.util.List; @@ -56,6 +60,14 @@ public class MediaRouteManager extends MediaRouter.Callback { public MediaRouteManager(DownloadService downloadService) { this.downloadService = downloadService; router = MediaRouter.getInstance(downloadService); + + // Check if play services is available + int result = GooglePlayServicesUtil.isGooglePlayServicesAvailable(downloadService); + if(result != ConnectionResult.SUCCESS){ + Log.w(TAG, "No play services, failed with result: " + result); + castAvailable = false; + } + addProviders(); buildSelector(); } @@ -140,7 +152,7 @@ public class MediaRouteManager extends MediaRouter.Callback { } private void buildSelector() { MediaRouteSelector.Builder builder = new MediaRouteSelector.Builder(); - builder.addControlCategory(MediaControlIntent.CATEGORY_REMOTE_PLAYBACK); + builder.addControlCategory(JukeboxRouteProvider.CATEGORY_JUKEBOX_ROUTE); if(castAvailable) { builder.addControlCategory(CastCompat.getCastControlCategory()); } -- cgit v1.2.3