summaryrefslogtreecommitdiffstats
path: root/tests/OneMedia/src
diff options
context:
space:
mode:
authorRoboErik <epastern@google.com>2014-04-23 14:38:17 -0700
committerErik Pasternak <roboerik@android.com>2014-05-01 17:14:01 +0000
commitf1372428f2df781c71c71caa2f6a4db6f847cf10 (patch)
tree62b260454c523adda9dbd7ced72f273f7231edc6 /tests/OneMedia/src
parent4e8cf1508f22f88203cd9bf4467aaddd3f4502c6 (diff)
downloadframeworks_base-f1372428f2df781c71c71caa2f6a4db6f847cf10.zip
frameworks_base-f1372428f2df781c71c71caa2f6a4db6f847cf10.tar.gz
frameworks_base-f1372428f2df781c71c71caa2f6a4db6f847cf10.tar.bz2
Add Session API calls to RCC and AudioManager
This makes RCC and MediaButtonReceiver (via AudioManager) also use the new Session APIs in parallel to their existing code. This will allow us to bring up the Session compatibility pieces without disrupting the old behavior and then switch everything over to just using the new APIs when ready. Change-Id: I33ce0a044dea3ec763f2302b91a5e415be27d4a4
Diffstat (limited to 'tests/OneMedia/src')
-rw-r--r--tests/OneMedia/src/com/android/onemedia/PlayerSession.java31
-rw-r--r--tests/OneMedia/src/com/android/onemedia/provider/OneMediaRouteProvider.java21
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