summaryrefslogtreecommitdiffstats
path: root/samples/Support7Demos
diff options
context:
space:
mode:
authorJae Seo <jaeseo@google.com>2015-08-18 10:15:11 -0700
committerJae Seo <jaeseo@google.com>2015-08-18 16:00:05 -0700
commitcbfd7cd50690838517bebb2ea93316729b1a29d0 (patch)
tree889dc079106ef6e16097a168e569bc7a595a4851 /samples/Support7Demos
parenta3df99100ad3e3d1a8321ab86422d5ebca4345a7 (diff)
downloadandroid_development-cbfd7cd50690838517bebb2ea93316729b1a29d0.tar.gz
android_development-cbfd7cd50690838517bebb2ea93316729b1a29d0.tar.bz2
android_development-cbfd7cd50690838517bebb2ea93316729b1a29d0.zip
MediaRouter: Add route groups
Change-Id: Ideab1c0fccd01a68e3f6a5997b9c66aed9b1332e
Diffstat (limited to 'samples/Support7Demos')
-rw-r--r--samples/Support7Demos/res/values/strings.xml2
-rw-r--r--samples/Support7Demos/src/com/example/android/supportv7/media/SampleMediaRouteProvider.java53
2 files changed, 43 insertions, 12 deletions
diff --git a/samples/Support7Demos/res/values/strings.xml b/samples/Support7Demos/res/values/strings.xml
index accf739d1..1f42fe85c 100644
--- a/samples/Support7Demos/res/values/strings.xml
+++ b/samples/Support7Demos/res/values/strings.xml
@@ -36,6 +36,8 @@
<string name="variable_volume_basic_route_name">Variable Volume (Basic) Remote Playback Route</string>
<string name="variable_volume_queuing_route_name">Variable Volume (Queuing) Remote Playback Route</string>
<string name="variable_volume_session_route_name">Variable Volume (Session) Remote Playback Route</string>
+ <string name="variable_volume_route_group_name">Variable Volume Route Group</string>
+ <string name="mixed_volume_route_group_name">Mixed Volume Route Group</string>
<string name="sample_route_description">Sample route from Support7Demos</string>
<!-- GridLayout -->
diff --git a/samples/Support7Demos/src/com/example/android/supportv7/media/SampleMediaRouteProvider.java b/samples/Support7Demos/src/com/example/android/supportv7/media/SampleMediaRouteProvider.java
index 15cf19b7d..7bd6e6f4d 100644
--- a/samples/Support7Demos/src/com/example/android/supportv7/media/SampleMediaRouteProvider.java
+++ b/samples/Support7Demos/src/com/example/android/supportv7/media/SampleMediaRouteProvider.java
@@ -16,31 +16,26 @@
package com.example.android.supportv7.media;
-import com.example.android.supportv7.R;
-
+import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.IntentFilter.MalformedMimeTypeException;
import android.content.IntentSender;
import android.content.res.Resources;
-import android.graphics.Bitmap;
import android.media.AudioManager;
import android.media.MediaRouter;
import android.net.Uri;
import android.os.Bundle;
-import android.app.PendingIntent;
import android.support.v7.media.MediaControlIntent;
-import android.support.v7.media.MediaItemStatus;
+import android.support.v7.media.MediaRouteDescriptor;
import android.support.v7.media.MediaRouteProvider;
-import android.support.v7.media.MediaRouter.ControlRequestCallback;
import android.support.v7.media.MediaRouteProviderDescriptor;
-import android.support.v7.media.MediaRouteDescriptor;
+import android.support.v7.media.MediaRouter.ControlRequestCallback;
import android.support.v7.media.MediaSessionStatus;
import android.util.Log;
-import android.view.Gravity;
-import android.view.Surface;
-import android.view.SurfaceHolder;
+
+import com.example.android.supportv7.R;
import java.util.ArrayList;
@@ -56,6 +51,9 @@ final class SampleMediaRouteProvider extends MediaRouteProvider {
private static final String VARIABLE_VOLUME_BASIC_ROUTE_ID = "variable_basic";
private static final String VARIABLE_VOLUME_QUEUING_ROUTE_ID = "variable_queuing";
private static final String VARIABLE_VOLUME_SESSION_ROUTE_ID = "variable_session";
+ private static final String VARIABLE_VOLUME_ROUTE_GROUP_ID = "variable_group";
+ private static final String MIXED_VOLUME_ROUTE_GROUP_ID = "mixed_group";
+
private static final int VOLUME_MAX = 10;
/**
@@ -230,12 +228,43 @@ final class SampleMediaRouteProvider extends MediaRouteProvider {
.setVolume(mVolume)
.build();
- MediaRouteProviderDescriptor providerDescriptor =
- new MediaRouteProviderDescriptor.Builder()
+ MediaRouteDescriptor routeDescriptor5 = new MediaRouteDescriptor.Builder(
+ VARIABLE_VOLUME_ROUTE_GROUP_ID,
+ r.getString(R.string.variable_volume_route_group_name))
+ .addChildId(VARIABLE_VOLUME_BASIC_ROUTE_ID)
+ .addChildId(VARIABLE_VOLUME_QUEUING_ROUTE_ID)
+ .addChildId(VARIABLE_VOLUME_SESSION_ROUTE_ID)
+ .setDescription(r.getString(R.string.sample_route_description))
+ .addControlFilters(CONTROL_FILTERS_SESSION)
+ .setPlaybackStream(AudioManager.STREAM_MUSIC)
+ .setPlaybackType(MediaRouter.RouteInfo.PLAYBACK_TYPE_REMOTE)
+ .setVolumeHandling(MediaRouter.RouteInfo.PLAYBACK_VOLUME_VARIABLE)
+ .setVolumeMax(VOLUME_MAX)
+ .setVolume(mVolume)
+ .build();
+
+ MediaRouteDescriptor routeDescriptor6 = new MediaRouteDescriptor.Builder(
+ MIXED_VOLUME_ROUTE_GROUP_ID,
+ r.getString(R.string.mixed_volume_route_group_name))
+ .addChildId(FIXED_VOLUME_ROUTE_ID)
+ .addChildId(VARIABLE_VOLUME_BASIC_ROUTE_ID)
+ .addChildId(VARIABLE_VOLUME_QUEUING_ROUTE_ID)
+ .setDescription(r.getString(R.string.sample_route_description))
+ .addControlFilters(CONTROL_FILTERS_SESSION)
+ .setPlaybackStream(AudioManager.STREAM_MUSIC)
+ .setPlaybackType(MediaRouter.RouteInfo.PLAYBACK_TYPE_REMOTE)
+ .setVolumeHandling(MediaRouter.RouteInfo.PLAYBACK_VOLUME_VARIABLE)
+ .setVolumeMax(VOLUME_MAX)
+ .setVolume(mVolume)
+ .build();
+
+ MediaRouteProviderDescriptor providerDescriptor = new MediaRouteProviderDescriptor.Builder()
.addRoute(routeDescriptor1)
.addRoute(routeDescriptor2)
.addRoute(routeDescriptor3)
.addRoute(routeDescriptor4)
+ .addRoute(routeDescriptor5)
+ .addRoute(routeDescriptor6)
.build();
setDescriptor(providerDescriptor);
}