use of android.support.v7.media.MediaSessionStatus in project cw-omnibus by commonsguy.
the class PlaybackFragment method play.
private void play() {
logToTranscript(getActivity().getString(R.string.play_requested));
ItemActionCallback playCB = new ItemActionCallback() {
@Override
public void onResult(Bundle data, String sessionId, MediaSessionStatus sessionStatus, String itemId, MediaItemStatus itemStatus) {
logToTranscript(getActivity().getString(R.string.playing));
isPlaying = true;
getActivity().supportInvalidateOptionsMenu();
}
@Override
public void onError(String error, int code, Bundle data) {
logToTranscript(getActivity().getString(R.string.play_error) + error);
}
};
client.play(Uri.parse("http://misc.commonsware.com/ed_hd_512kb.mp4"), "video/mp4", null, 0, null, playCB);
}
use of android.support.v7.media.MediaSessionStatus in project cw-omnibus by commonsguy.
the class PlaybackFragment method connect.
private void connect(MediaRouter.RouteInfo route) {
client = new RemotePlaybackClient(getActivity().getApplication(), route);
if (client.isRemotePlaybackSupported()) {
logToTranscript(getActivity().getString(R.string.connected));
if (client.isSessionManagementSupported()) {
client.startSession(null, new SessionActionCallback() {
@Override
public void onResult(Bundle data, String sessionId, MediaSessionStatus sessionStatus) {
logToTranscript(getActivity().getString(R.string.session_started));
getActivity().supportInvalidateOptionsMenu();
}
@Override
public void onError(String error, int code, Bundle data) {
logToTranscript(getActivity().getString(R.string.session_failed));
}
});
} else {
getActivity().supportInvalidateOptionsMenu();
}
} else {
logToTranscript(getActivity().getString(R.string.remote_playback_not_supported));
client = null;
}
}
use of android.support.v7.media.MediaSessionStatus in project cw-omnibus by commonsguy.
the class PlaybackFragment method connect.
private void connect(MediaRouter.RouteInfo route) {
client = new RemotePlaybackClient(getActivity().getApplication(), route);
if (client.isRemotePlaybackSupported()) {
logToTranscript(getActivity().getString(R.string.connected));
if (client.isSessionManagementSupported()) {
client.startSession(null, new SessionActionCallback() {
@Override
public void onResult(Bundle data, String sessionId, MediaSessionStatus sessionStatus) {
logToTranscript(getActivity().getString(R.string.session_started));
updateMenu();
}
@Override
public void onError(String error, int code, Bundle data) {
logToTranscript(getActivity().getString(R.string.session_failed));
}
});
} else {
getActivity().supportInvalidateOptionsMenu();
}
} else {
logToTranscript(getActivity().getString(R.string.remote_playback_not_supported));
client = null;
}
}
use of android.support.v7.media.MediaSessionStatus in project cw-omnibus by commonsguy.
the class PlaybackFragment method play.
private void play() {
logToTranscript(getActivity().getString(R.string.play_requested));
ItemActionCallback playCB = new ItemActionCallback() {
@Override
public void onResult(Bundle data, String sessionId, MediaSessionStatus sessionStatus, String itemId, MediaItemStatus itemStatus) {
logToTranscript(getActivity().getString(R.string.playing));
isPlaying = true;
updateMenu();
}
@Override
public void onError(String error, int code, Bundle data) {
logToTranscript(getActivity().getString(R.string.play_error) + error);
}
};
client.play(Uri.parse("http://misc.commonsware.com/ed_hd_512kb.mp4"), "video/mp4", null, 0, null, playCB);
}
use of android.support.v7.media.MediaSessionStatus in project AndroidChromium by JackyAndroid.
the class DefaultMediaRouteController method processSessionStatusBundle.
private void processSessionStatusBundle(Bundle statusBundle) {
MediaSessionStatus status = MediaSessionStatus.fromBundle(statusBundle.getBundle(MediaControlIntent.EXTRA_SESSION_STATUS));
int sessionState = status.getSessionState();
// If no change do nothing
if (sessionState == mSessionState)
return;
mSessionState = sessionState;
switch(sessionState) {
case MediaSessionStatus.SESSION_STATE_ACTIVE:
if (mLocalVideoUri != null) {
startPlayback(mPreferredTitle, mStartPositionMillis);
}
break;
case MediaSessionStatus.SESSION_STATE_ENDED:
case MediaSessionStatus.SESSION_STATE_INVALIDATED:
for (UiListener listener : getUiListeners()) {
listener.onPlaybackStateChanged(PlayerState.INVALIDATED);
}
if (getMediaStateListener() != null) {
getMediaStateListener().onPlaybackStateChanged(PlayerState.INVALIDATED);
}
// Record the remaining time UMA first, otherwise the playback state will be cleared
// in release().
recordRemainingTimeUMA();
// Set the current session id to null so we don't send the stop intent.
mCurrentSessionId = null;
release();
break;
default:
break;
}
}
Aggregations