import android.support.v7.media.MediaSessionStatus; //导入方法依赖的package包/类
private void processSessionStatusBundle(Bundle statusBundle) {
Log.d(TAG, "processSessionStatusBundle()");
String sessionId = statusBundle.getString(MediaControlIntent.EXTRA_SESSION_ID);
MediaSessionStatus status = MediaSessionStatus.fromBundle(
statusBundle.getBundle(MediaControlIntent.EXTRA_SESSION_STATUS));
int sessionState = status.getSessionState();
Log.d(TAG, "got a session status update for session " + sessionId + ", state = "
+ sessionState + ", mSessionId=" + mSessionId);
if (mSessionId == null) {
return;
}
if (!mSessionId.equals(sessionId)) {
// Got status on a session other than the one we're tracking. Ignore it.
Log.d(TAG, "Received status for unknown session: " + sessionId);
return;
}
switch (sessionState) {
case MediaSessionStatus.SESSION_STATE_ACTIVE:
Log.d(TAG, "session " + sessionId + " is ACTIVE");
mSessionActive = true;
syncStatus();
break;
case MediaSessionStatus.SESSION_STATE_ENDED:
Log.d(TAG, "session " + sessionId + " is ENDED");
mSessionId = null;
mSessionActive = false;
clearCurrentMediaItem();
break;
case MediaSessionStatus.SESSION_STATE_INVALIDATED:
Log.d(TAG, "session " + sessionId + " is INVALIDATED");
mSessionId = null;
mSessionActive = false;
clearCurrentMediaItem();
break;
default:
Log.d(TAG, "Received unexpected session state: " + sessionState);
break;
}
updateButtonStates();
}