summaryrefslogtreecommitdiffstats
path: root/samples
diff options
context:
space:
mode:
authorJeff Brown <jeffbrown@google.com>2013-09-27 17:55:55 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2013-09-27 17:55:55 -0700
commitca5521ed66d3f403d893f087f794b9c595a69593 (patch)
treedc8353d2345ec4dd1bc9b0be2abefdd54aa56ad0 /samples
parent4e2a591cd87b4678ecf74330e2f207692e89c8b9 (diff)
parent5d3d35ee89ccd2bc02a65af03d46ea031c8cf73a (diff)
downloadandroid_development-ca5521ed66d3f403d893f087f794b9c595a69593.tar.gz
android_development-ca5521ed66d3f403d893f087f794b9c595a69593.tar.bz2
android_development-ca5521ed66d3f403d893f087f794b9c595a69593.zip
am 5d3d35ee: Always register the RCC even for local playback.
* commit '5d3d35ee89ccd2bc02a65af03d46ea031c8cf73a': Always register the RCC even for local playback.
Diffstat (limited to 'samples')
-rw-r--r--samples/Support7Demos/src/com/example/android/supportv7/media/SampleMediaRouterActivity.java53
1 files changed, 31 insertions, 22 deletions
diff --git a/samples/Support7Demos/src/com/example/android/supportv7/media/SampleMediaRouterActivity.java b/samples/Support7Demos/src/com/example/android/supportv7/media/SampleMediaRouterActivity.java
index 04d57a068..7f621800c 100644
--- a/samples/Support7Demos/src/com/example/android/supportv7/media/SampleMediaRouterActivity.java
+++ b/samples/Support7Demos/src/com/example/android/supportv7/media/SampleMediaRouterActivity.java
@@ -134,7 +134,7 @@ public class SampleMediaRouterActivity extends ActionBarActivity {
@Override
public void onSizeChanged(int width, int height) {
- mLocalPlayer.updateSize(width, height);
+ mPlayer.updateSize(width, height);
}
@Override
@@ -197,16 +197,11 @@ public class SampleMediaRouterActivity extends ActionBarActivity {
playerCB = mRemotePlayer;
mRemotePlayer.reset();
- // Create and register the remote control client
- registerRCC();
} else {
// Local Playback:
// Use local player and feed media player one item at a time
player = mLocalPlayer;
playerCB = mMediaPlayer;
-
- // Unregister the remote control client
- unregisterRCC();
}
if (player != mPlayer || playerCB != mPlayerCB) {
@@ -506,6 +501,9 @@ public class SampleMediaRouterActivity extends ActionBarActivity {
Intent mediaButtonIntent = new Intent(Intent.ACTION_MEDIA_BUTTON);
mediaButtonIntent.setComponent(mEventReceiver);
mMediaPendingIntent = PendingIntent.getBroadcast(this, 0, mediaButtonIntent, 0);
+
+ // Create and register the remote control client
+ registerRCC();
}
private void registerRCC() {
@@ -620,10 +618,14 @@ public class SampleMediaRouterActivity extends ActionBarActivity {
@Override
public void onDestroy() {
+ // Unregister the remote control client
+ unregisterRCC();
+
// Unregister broadcast receiver
unregisterReceiver(mReceiver);
mPlayer.stop();
mMediaPlayer.release();
+
super.onDestroy();
}
@@ -768,19 +770,20 @@ public class SampleMediaRouterActivity extends ActionBarActivity {
toast.show();
}
- private abstract class Player {
- abstract void enqueue(final Uri uri, long pos);
- abstract void remove(final MediaQueueItem item);
- abstract void seek(String sid, String iid, long pos);
- abstract void getStatus(final MediaQueueItem item, final boolean update);
- abstract void pause();
- abstract void resume();
- abstract void stop();
- abstract void showStatistics();
- abstract void onFinish(boolean error);
+ private interface Player {
+ void enqueue(final Uri uri, long pos);
+ void remove(final MediaQueueItem item);
+ void seek(String sid, String iid, long pos);
+ void getStatus(final MediaQueueItem item, final boolean update);
+ void pause();
+ void resume();
+ void stop();
+ void showStatistics();
+ void onFinish(boolean error);
+ void updateSize(int width, int height);
}
- private class LocalPlayer extends Player implements SurfaceHolder.Callback {
+ private class LocalPlayer implements Player, SurfaceHolder.Callback {
private final MediaSessionManager mSessionManager = new MediaSessionManager();
private String mSessionId;
// The presentation to show on the secondary display.
@@ -795,7 +798,7 @@ public class SampleMediaRouterActivity extends ActionBarActivity {
mSurfaceView = (SurfaceView)findViewById(R.id.surface_view);
SurfaceHolder holder = mSurfaceView.getHolder();
holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
- holder.addCallback(mLocalPlayer);
+ holder.addCallback(this);
}
public void setCallback(MediaSessionManager.Callback cb) {
@@ -911,7 +914,7 @@ public class SampleMediaRouterActivity extends ActionBarActivity {
public void surfaceCreated(SurfaceHolder holder) {
Log.d(TAG, "surfaceCreated");
mMediaPlayer.setSurface(holder);
- mLocalPlayer.updateSize(mVideoWidth, mVideoHeight);
+ updateSize(mVideoWidth, mVideoHeight);
}
@Override
@@ -919,7 +922,8 @@ public class SampleMediaRouterActivity extends ActionBarActivity {
Log.d(TAG, "surfaceDestroyed");
}
- private void updateSize(int width, int height) {
+ @Override
+ public void updateSize(int width, int height) {
if (width > 0 && height > 0) {
if (mPresentation == null) {
int surfaceWidth = mLayout.getWidth();
@@ -1028,7 +1032,7 @@ public class SampleMediaRouterActivity extends ActionBarActivity {
mPresentationSurfaceView = (SurfaceView)findViewById(R.id.surface_view);
SurfaceHolder holder = mPresentationSurfaceView.getHolder();
holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
- holder.addCallback(mLocalPlayer);
+ holder.addCallback(LocalPlayer.this);
}
public void updateSize(int width, int height) {
@@ -1048,7 +1052,7 @@ public class SampleMediaRouterActivity extends ActionBarActivity {
}
}
- private class RemotePlayer extends Player implements MediaSessionManager.Callback {
+ private class RemotePlayer implements Player, MediaSessionManager.Callback {
private MediaQueueItem mQueueItem;
private MediaQueueItem mPlaylistItem;
private String mSessionId;
@@ -1363,6 +1367,11 @@ public class SampleMediaRouterActivity extends ActionBarActivity {
updateUi();
}
+ @Override
+ public void updateSize(int width, int height) {
+ // nothing to do
+ }
+
private void play(final Uri uri, boolean enqueue, final long pos) {
// save the initial seek position
mPosition = pos;