Search in sources :

Example 1 with MessageReceivedCallback

use of com.google.android.gms.cast.Cast.MessageReceivedCallback in project zype-android by zype.

the class VideoCastManager method attachDataChannel.

/*
     * If a data namespace was provided when initializing this class, we set things up for a data
     * channel
     *
     * @throws NoConnectionException
     * @throws TransientNetworkDisconnectionException
     */
private void attachDataChannel() throws TransientNetworkDisconnectionException, NoConnectionException {
    if (TextUtils.isEmpty(mDataNamespace)) {
        return;
    }
    if (mDataChannel != null) {
        return;
    }
    checkConnectivity();
    mDataChannel = new MessageReceivedCallback() {

        @Override
        public void onMessageReceived(CastDevice castDevice, String namespace, String message) {
            for (VideoCastConsumer consumer : mVideoConsumers) {
                consumer.onDataMessageReceived(message);
            }
        }
    };
    try {
        Cast.CastApi.setMessageReceivedCallbacks(mApiClient, mDataNamespace, mDataChannel);
    } catch (IOException | IllegalStateException e) {
        LOGE(TAG, "attachDataChannel()", e);
    }
}
Also used : VideoCastConsumer(com.google.android.libraries.cast.companionlibrary.cast.callbacks.VideoCastConsumer) CastDevice(com.google.android.gms.cast.CastDevice) IOException(java.io.IOException) MessageReceivedCallback(com.google.android.gms.cast.Cast.MessageReceivedCallback)

Example 2 with MessageReceivedCallback

use of com.google.android.gms.cast.Cast.MessageReceivedCallback in project Shuttle by timusus.

the class VideoCastManager method attachDataChannel.

/*
     * If a data namespace was provided when initializing this class, we set things up for a data
     * channel
     *
     * @throws NoConnectionException
     * @throws TransientNetworkDisconnectionException
     */
private void attachDataChannel() throws TransientNetworkDisconnectionException, NoConnectionException {
    if (TextUtils.isEmpty(mDataNamespace)) {
        return;
    }
    if (mDataChannel != null) {
        return;
    }
    checkConnectivity();
    mDataChannel = new MessageReceivedCallback() {

        @Override
        public void onMessageReceived(CastDevice castDevice, String namespace, String message) {
            for (VideoCastConsumer consumer : mVideoConsumers) {
                consumer.onDataMessageReceived(message);
            }
        }
    };
    try {
        Cast.CastApi.setMessageReceivedCallbacks(mApiClient, mDataNamespace, mDataChannel);
    } catch (IOException | IllegalStateException e) {
        LOGE(TAG, "attachDataChannel()", e);
    }
}
Also used : VideoCastConsumer(com.google.android.libraries.cast.companionlibrary.cast.callbacks.VideoCastConsumer) CastDevice(com.google.android.gms.cast.CastDevice) IOException(java.io.IOException) MessageReceivedCallback(com.google.android.gms.cast.Cast.MessageReceivedCallback)

Aggregations

MessageReceivedCallback (com.google.android.gms.cast.Cast.MessageReceivedCallback)2 CastDevice (com.google.android.gms.cast.CastDevice)2 VideoCastConsumer (com.google.android.libraries.cast.companionlibrary.cast.callbacks.VideoCastConsumer)2 IOException (java.io.IOException)2