diff options
author | RoboErik <epastern@google.com> | 2014-08-06 13:43:22 -0700 |
---|---|---|
committer | RoboErik <epastern@google.com> | 2014-08-07 16:54:52 -0700 |
commit | 477d1197c3c25c01ace7ea4494437c23720a2eb3 (patch) | |
tree | 515faf9a92502ca4fe27388ac373eaa4771cbfa2 /tests/OneMedia | |
parent | 217e8a2b4661d3ae6dc470a8dc07b3145c560c7e (diff) | |
download | frameworks_base-477d1197c3c25c01ace7ea4494437c23720a2eb3.zip frameworks_base-477d1197c3c25c01ace7ea4494437c23720a2eb3.tar.gz frameworks_base-477d1197c3c25c01ace7ea4494437c23720a2eb3.tar.bz2 |
Combine MediaSession Callback and TransportControlsCallback
This combines them into a single Callback class and adds default
handling to media buttons to check the available actions and call
one of the other methods if appropriate.
Change-Id: If9897d8cf6d8d8046aa85a646c22382f1db1461b
Diffstat (limited to 'tests/OneMedia')
-rw-r--r-- | tests/OneMedia/src/com/android/onemedia/PlayerSession.java | 28 |
1 files changed, 4 insertions, 24 deletions
diff --git a/tests/OneMedia/src/com/android/onemedia/PlayerSession.java b/tests/OneMedia/src/com/android/onemedia/PlayerSession.java index feecfde..890d68d 100644 --- a/tests/OneMedia/src/com/android/onemedia/PlayerSession.java +++ b/tests/OneMedia/src/com/android/onemedia/PlayerSession.java @@ -86,10 +86,10 @@ public class PlayerSession { mRouter.setRoutingCallback(new RoutingCallback(), null); mSession = new MediaSession(mContext, "OneMedia"); - mSession.addCallback(mCallback); - mSession.addTransportControlsCallback(new TransportCallback()); + mSession.setCallback(mCallback); mSession.setPlaybackState(mPlaybackState); - mSession.setFlags(MediaSession.FLAG_HANDLES_TRANSPORT_CONTROLS); + mSession.setFlags(MediaSession.FLAG_HANDLES_TRANSPORT_CONTROLS + | MediaSession.FLAG_HANDLES_MEDIA_BUTTONS); mSession.setMediaRouter(mRouter); mSession.setActive(true); } @@ -230,26 +230,6 @@ public class PlayerSession { private class SessionCb extends MediaSession.Callback { @Override - public void onMediaButtonEvent(Intent mediaRequestIntent) { - if (Intent.ACTION_MEDIA_BUTTON.equals(mediaRequestIntent.getAction())) { - KeyEvent event = (KeyEvent) mediaRequestIntent - .getParcelableExtra(Intent.EXTRA_KEY_EVENT); - switch (event.getKeyCode()) { - case KeyEvent.KEYCODE_MEDIA_PLAY: - Log.d(TAG, "play button received"); - mRenderer.onPlay(); - break; - case KeyEvent.KEYCODE_MEDIA_PAUSE: - Log.d(TAG, "pause button received"); - mRenderer.onPause(); - break; - } - } - } - } - - private class TransportCallback extends MediaSession.TransportControlsCallback { - @Override public void onPlay() { mRenderer.onPlay(); } @@ -315,7 +295,7 @@ public class PlayerSession { updateState(PlaybackState.STATE_NONE); break; } - } + } } } } |