diff options
author | Jeff Brown <jeffbrown@google.com> | 2013-09-27 17:58:25 -0700 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2013-09-27 17:58:25 -0700 |
commit | ebc9c692f2fdc053e5be82407bc6755cb1153e3b (patch) | |
tree | a450591e4ad6f77b902c54d4bd8ee7d81d36963d /samples | |
parent | 53b8075b98b16fe501dddff2bf13bbd8c01f8385 (diff) | |
parent | ca5521ed66d3f403d893f087f794b9c595a69593 (diff) | |
download | android_development-ebc9c692f2fdc053e5be82407bc6755cb1153e3b.tar.gz android_development-ebc9c692f2fdc053e5be82407bc6755cb1153e3b.tar.bz2 android_development-ebc9c692f2fdc053e5be82407bc6755cb1153e3b.zip |
am ca5521ed: am 5d3d35ee: Always register the RCC even for local playback.
* commit 'ca5521ed66d3f403d893f087f794b9c595a69593':
Always register the RCC even for local playback.
Diffstat (limited to 'samples')
-rw-r--r-- | samples/Support7Demos/src/com/example/android/supportv7/media/SampleMediaRouterActivity.java | 53 |
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 a534eee0a..cad1584d3 100644 --- a/samples/Support7Demos/src/com/example/android/supportv7/media/SampleMediaRouterActivity.java +++ b/samples/Support7Demos/src/com/example/android/supportv7/media/SampleMediaRouterActivity.java @@ -135,7 +135,7 @@ public class SampleMediaRouterActivity extends ActionBarActivity { @Override public void onSizeChanged(int width, int height) { - mLocalPlayer.updateSize(width, height); + mPlayer.updateSize(width, height); } @Override @@ -198,16 +198,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) { @@ -510,6 +505,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() { @@ -624,10 +622,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(); } @@ -772,19 +774,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. @@ -799,7 +802,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) { @@ -915,7 +918,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 @@ -923,7 +926,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(); @@ -1032,7 +1036,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) { @@ -1052,7 +1056,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; @@ -1367,6 +1371,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; |