CastReceiverContext

public classCastReceiverContextextendsObject

The singleton class as the entry point of the Cast TV SDK.

Nested Class Summary

class CastReceiverContext.EventCallback Callback class for observing various events.
interface CastReceiverContext.MessageReceivedListener Listener for listening messages that come from the sender.

Public Method Summary

staticCastReceiverContext
getInstance()
Returns the shared instance.
MediaManager
CastReceiverOptions
getReceiverOptions()
Returns the receiver options.
SenderInfo
getSender(StringsenderId)
Returns theSenderInfo with the givensenderId.
Collection<SenderInfo>
getSenders()
Returns all senders.
static void
initInstance(Context context)
Initializes the shared instance.
void
void
removeMessageReceivedListener(Stringnamespace)
Removes a listener for a given namespace.
void
sendMessage(Stringnamespace, String senderId,Stringmessage)
Sends a message to a specific sender.
void
setMessageReceivedListener(Stringnamespace, CastReceiverContext.MessageReceivedListenerlistener)
Sets a listener for a given namespace.
void
start()
Tells the Cast TV SDK that the receiver app has started and is ready to accept commands.
void
stop()
Tells the Cast TV SDK that the receiver app has stopped and won't accept commands any more.
void

Inherited Method Summary

Public Methods

public staticCastReceiverContext getInstance()

Returns the shared instance. Returnsnullif the instance hasn't been initialized.

publicMediaManager getMediaManager()

Returns theMediaManager.

publicCastReceiverOptions getReceiverOptions()

Returns the receiver options.

publicSenderInfo getSender(StringsenderId)

Returns theSenderInfo with the givensenderId.Returnsnullif not found.

publicCollection<SenderInfo> getSenders()

Returns all senders.

public static voidinitInstance(Context context)

Initializes the shared instance.

public voidregisterEventCallback(CastReceiverContext.EventCallback callback)

public voidremoveMessageReceivedListener(String namespace)

Removes a listener for a given namespace.

public voidsendMessage(Stringnamespace,StringsenderId,Stringmessage)

Sends a message to a specific sender.

Parameters
namespace the namespace. Note that a valid namespace has to be prefixed with the string 'urn:x-cast:'
senderId the sender Id, ornullfor broadcast to all senders
message the message

public voidsetMessageReceivedListener(Stringnamespace, CastReceiverContext.MessageReceivedListenerlistener)

Sets a listener for a given namespace.

Will replace a listener for the namespace if there is one.

public voidstart()

Tells the Cast TV SDK that the receiver app has started and is ready to accept commands.

TheMediaCommandCallback and CastReceiverContext.MessageReceivedListenerwill be invoked if new messages arrive.

public voidstop()

Tells the Cast TV SDK that the receiver app has stopped and won't accept commands any more.

TheMediaCommandCallback and CastReceiverContext.MessageReceivedListenerwill no longer be invoked.

public voidunregisterEventCallback(CastReceiverContext.EventCallback callback)