Methods Summary |
---|
public void | createSession()
releaseSession();
MediaSessionManager man = (MediaSessionManager) mContext
.getSystemService(Context.MEDIA_SESSION_SERVICE);
Log.d(TAG, "Creating session for package " + mContext.getBasePackageName());
mSession = new MediaSession(mContext, "OneMedia");
mSession.setCallback(mCallback);
mSession.setPlaybackState(mPlaybackState);
mSession.setFlags(MediaSession.FLAG_HANDLES_TRANSPORT_CONTROLS
| MediaSession.FLAG_HANDLES_MEDIA_BUTTONS);
mSession.setActive(true);
updateMetadata();
|
public MediaSession.Token | getSessionToken()
return mSession.getSessionToken();
|
private void | initMetadata()
mMetadataBuilder = new MediaMetadata.Builder();
mMetadataBuilder.putString(MediaMetadata.METADATA_KEY_DISPLAY_TITLE,
"OneMedia display title");
mMetadataBuilder.putString(MediaMetadata.METADATA_KEY_DISPLAY_SUBTITLE,
"OneMedia display subtitle");
mQueue.add(new QueueItem(mMetadataBuilder.build().getDescription(), 11));
|
public void | onDestroy()
releaseSession();
if (mRenderer != null) {
mRenderer.unregisterListener(mRenderListener);
mRenderer.onDestroy();
}
|
private void | releaseSession()
if (mSession != null) {
mSession.release();
mSession = null;
}
|
public void | setContent(android.os.Bundle request)
mRenderer.setContent(request);
mContent = request.getString(RequestUtils.EXTRA_KEY_SOURCE);
|
public void | setIcon(android.graphics.Bitmap icon)
mMetadataBuilder.putBitmap(MediaMetadata.METADATA_KEY_DISPLAY_ICON, icon);
mQueue.clear();
mQueue.add(new QueueItem(mMetadataBuilder.build().getDescription(), 11));
updateMetadata();
|
public void | setListener(com.android.onemedia.PlayerSession$Listener listener)
mListener = listener;
|
public void | setNextContent(android.os.Bundle request)
mRenderer.setNextContent(request);
|
private void | updateMetadata()
// This is a mild abuse of metadata and shouldn't be duplicated in real
// code
if (mSession != null && mSession.isActive()) {
mSession.setMetadata(mMetadataBuilder.build());
// Just toggle the queue every time we update for testing
mSession.setQueue(mUseQueue ? mQueue : null);
mSession.setQueueTitle(mUseQueue ? "Queue title" : null);
mUseQueue = !mUseQueue;
}
|
private void | updateState(int newState)
float rate = newState == PlaybackState.STATE_PLAYING ? 1 : 0;
long position = mRenderer == null ? -1 : mRenderer.getSeekPosition();
PlaybackState.Builder bob = new PlaybackState.Builder(mPlaybackState);
bob.setState(newState, position, rate, SystemClock.elapsedRealtime());
bob.setErrorMessage(null);
mPlaybackState = bob.build();
mSession.setPlaybackState(mPlaybackState);
|