diff options
author | Scott Jackson <daneren2005@gmail.com> | 2014-03-25 19:56:00 -0700 |
---|---|---|
committer | Scott Jackson <daneren2005@gmail.com> | 2014-03-25 19:56:00 -0700 |
commit | 9efb112d3dcf0ce8a9419daa050c29e17fe824ad (patch) | |
tree | ba0d28c48a167cea47dccbd1d827de0800a33802 /src/github/daneren2005 | |
parent | 4478d6a4d17874415037701f7076097763edf885 (diff) | |
download | dsub-9efb112d3dcf0ce8a9419daa050c29e17fe824ad.tar.gz dsub-9efb112d3dcf0ce8a9419daa050c29e17fe824ad.tar.bz2 dsub-9efb112d3dcf0ce8a9419daa050c29e17fe824ad.zip |
Check for play services, fix cast showing up when cast_available = false
Diffstat (limited to 'src/github/daneren2005')
-rw-r--r-- | src/github/daneren2005/dsub/provider/JukeboxRouteProvider.java | 6 | ||||
-rw-r--r-- | src/github/daneren2005/dsub/util/MediaRouteManager.java | 14 |
2 files changed, 16 insertions, 4 deletions
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()); } |