Search in sources :

Example 1 with SessionActionCallback

use of android.support.v7.media.RemotePlaybackClient.SessionActionCallback 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;
    }
}
Also used : RemotePlaybackClient(android.support.v7.media.RemotePlaybackClient) MediaSessionStatus(android.support.v7.media.MediaSessionStatus) SessionActionCallback(android.support.v7.media.RemotePlaybackClient.SessionActionCallback) Bundle(android.os.Bundle)

Example 2 with SessionActionCallback

use of android.support.v7.media.RemotePlaybackClient.SessionActionCallback 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;
    }
}
Also used : RemotePlaybackClient(android.support.v7.media.RemotePlaybackClient) MediaSessionStatus(android.support.v7.media.MediaSessionStatus) SessionActionCallback(android.support.v7.media.RemotePlaybackClient.SessionActionCallback) Bundle(android.os.Bundle)

Aggregations

Bundle (android.os.Bundle)2 MediaSessionStatus (android.support.v7.media.MediaSessionStatus)2 RemotePlaybackClient (android.support.v7.media.RemotePlaybackClient)2 SessionActionCallback (android.support.v7.media.RemotePlaybackClient.SessionActionCallback)2