diff options
author | RoboErik <epastern@google.com> | 2014-05-01 17:14:56 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2014-05-01 17:14:56 +0000 |
commit | 6e6a6e863df6cc5e7b930b1197b1f6743ba31d8e (patch) | |
tree | 90700f3328f5e89ca92fcecd438cf9286519ad8d /tests | |
parent | 67e2196d07dd4dc1f3ce82fdaaa34cdbce89e1ce (diff) | |
parent | f1372428f2df781c71c71caa2f6a4db6f847cf10 (diff) | |
download | frameworks_base-6e6a6e863df6cc5e7b930b1197b1f6743ba31d8e.zip frameworks_base-6e6a6e863df6cc5e7b930b1197b1f6743ba31d8e.tar.gz frameworks_base-6e6a6e863df6cc5e7b930b1197b1f6743ba31d8e.tar.bz2 |
Merge "Add Session API calls to RCC and AudioManager"
Diffstat (limited to 'tests')
-rw-r--r-- | tests/OneMedia/src/com/android/onemedia/PlayerSession.java | 31 | ||||
-rw-r--r-- | tests/OneMedia/src/com/android/onemedia/provider/OneMediaRouteProvider.java | 21 |
2 files changed, 28 insertions, 24 deletions
diff --git a/tests/OneMedia/src/com/android/onemedia/PlayerSession.java b/tests/OneMedia/src/com/android/onemedia/PlayerSession.java index 5dc3904..2e029f0 100644 --- a/tests/OneMedia/src/com/android/onemedia/PlayerSession.java +++ b/tests/OneMedia/src/com/android/onemedia/PlayerSession.java @@ -119,7 +119,9 @@ public class PlayerSession { } private void updateState(int newState) { - mPlaybackState.setState(newState); + float rate = newState == PlaybackState.PLAYSTATE_PLAYING ? 1 : 0; + long position = mRenderer == null ? -1 : mRenderer.getSeekPosition(); + mPlaybackState.setState(newState, position, rate); mPerformer.setPlaybackState(mPlaybackState); } @@ -132,7 +134,7 @@ public class PlayerSession { @Override public void onError(int type, int extra, Bundle extras, Throwable error) { Log.d(TAG, "Sending onError with type " + type + " and extra " + extra); - mPlaybackState.setState(PlaybackState.PLAYSTATE_ERROR); + mPlaybackState.setState(PlaybackState.PLAYSTATE_ERROR, -1, 0); if (error != null) { mPlaybackState.setErrorMessage(error.getLocalizedMessage()); } @@ -147,34 +149,33 @@ public class PlayerSession { if (newState != Renderer.STATE_ERROR) { mPlaybackState.setErrorMessage(null); } + long position = -1; + if (mRenderer != null) { + position = mRenderer.getSeekPosition(); + } switch (newState) { case Renderer.STATE_ENDED: case Renderer.STATE_STOPPED: - mPlaybackState.setState(PlaybackState.PLAYSTATE_STOPPED); + mPlaybackState.setState(PlaybackState.PLAYSTATE_STOPPED, position, 0); break; case Renderer.STATE_INIT: case Renderer.STATE_PREPARING: - mPlaybackState.setState(PlaybackState.PLAYSTATE_BUFFERING); + mPlaybackState.setState(PlaybackState.PLAYSTATE_BUFFERING, position, 0); break; case Renderer.STATE_ERROR: - mPlaybackState.setState(PlaybackState.PLAYSTATE_ERROR); + mPlaybackState.setState(PlaybackState.PLAYSTATE_ERROR, position, 0); break; case Renderer.STATE_PAUSED: - mPlaybackState.setState(PlaybackState.PLAYSTATE_PAUSED); + mPlaybackState.setState(PlaybackState.PLAYSTATE_PAUSED, position, 0); break; case Renderer.STATE_PLAYING: - mPlaybackState.setState(PlaybackState.PLAYSTATE_PLAYING); + mPlaybackState.setState(PlaybackState.PLAYSTATE_PLAYING, position, 1); break; default: - mPlaybackState.setState(PlaybackState.PLAYSTATE_ERROR); + mPlaybackState.setState(PlaybackState.PLAYSTATE_ERROR, position, 0); mPlaybackState.setErrorMessage("unkown state"); break; } - if (mRenderer != null) { - mPlaybackState.setPosition(mRenderer.getSeekPosition()); - } else { - mPlaybackState.setPosition(-1); - } mPerformer.setPlaybackState(mPlaybackState); if (mListener != null) { mListener.onPlayStateChanged(mPlaybackState); @@ -188,8 +189,8 @@ public class PlayerSession { @Override public void onFocusLost() { Log.d(TAG, "Focus lost, changing state to " + Renderer.STATE_PAUSED); - mPlaybackState.setState(PlaybackState.PLAYSTATE_PAUSED); - mPlaybackState.setPosition(mRenderer.getSeekPosition()); + long position = mRenderer == null ? -1 : mRenderer.getSeekPosition(); + mPlaybackState.setState(PlaybackState.PLAYSTATE_PAUSED, position, 0); mPerformer.setPlaybackState(mPlaybackState); if (mListener != null) { mListener.onPlayStateChanged(mPlaybackState); diff --git a/tests/OneMedia/src/com/android/onemedia/provider/OneMediaRouteProvider.java b/tests/OneMedia/src/com/android/onemedia/provider/OneMediaRouteProvider.java index 6edcd7d..6537d49 100644 --- a/tests/OneMedia/src/com/android/onemedia/provider/OneMediaRouteProvider.java +++ b/tests/OneMedia/src/com/android/onemedia/provider/OneMediaRouteProvider.java @@ -158,30 +158,33 @@ public class OneMediaRouteProvider extends RouteProviderService { if (newState != Renderer.STATE_ERROR) { mPlaybackState.setErrorMessage(null); } + long position = -1; + if (mRenderer != null) { + position = mRenderer.getSeekPosition(); + } switch (newState) { case Renderer.STATE_ENDED: case Renderer.STATE_STOPPED: - mPlaybackState.setState(PlaybackState.PLAYSTATE_STOPPED); + mPlaybackState.setState(PlaybackState.PLAYSTATE_STOPPED, position, 0); break; case Renderer.STATE_INIT: case Renderer.STATE_PREPARING: - mPlaybackState.setState(PlaybackState.PLAYSTATE_BUFFERING); + mPlaybackState.setState(PlaybackState.PLAYSTATE_BUFFERING, position, 0); break; case Renderer.STATE_ERROR: - mPlaybackState.setState(PlaybackState.PLAYSTATE_ERROR); + mPlaybackState.setState(PlaybackState.PLAYSTATE_ERROR, position, 0); break; case Renderer.STATE_PAUSED: - mPlaybackState.setState(PlaybackState.PLAYSTATE_PAUSED); + mPlaybackState.setState(PlaybackState.PLAYSTATE_PAUSED, position, 0); break; case Renderer.STATE_PLAYING: - mPlaybackState.setState(PlaybackState.PLAYSTATE_PLAYING); + mPlaybackState.setState(PlaybackState.PLAYSTATE_PLAYING, position, 1); break; default: - mPlaybackState.setState(PlaybackState.PLAYSTATE_ERROR); + mPlaybackState.setState(PlaybackState.PLAYSTATE_ERROR, position, 0); mPlaybackState.setErrorMessage("unkown state"); break; } - mPlaybackState.setPosition(mRenderer.getSeekPosition()); mControls.sendPlaybackChangeEvent(mPlaybackState.getState()); } @@ -193,8 +196,8 @@ public class OneMediaRouteProvider extends RouteProviderService { @Override public void onFocusLost() { Log.d(TAG, "Focus lost, changing state to " + Renderer.STATE_PAUSED); - mPlaybackState.setState(PlaybackState.PLAYSTATE_PAUSED); - mPlaybackState.setPosition(mRenderer.getSeekPosition()); + mPlaybackState.setState(PlaybackState.PLAYSTATE_PAUSED, mRenderer.getSeekPosition(), 0); + mRenderer.onPause(); } @Override |