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
static CastReceiverContext |
getInstance()
Returns the shared instance.
|
MediaManager |
getMediaManager()
Returns the
MediaManager .
|
CastReceiverOptions |
getReceiverOptions()
Returns the receiver options.
|
SenderInfo | |
Collection<SenderInfo> |
getSenders()
Returns all senders.
|
static void | |
void |
registerEventCallback(CastReceiverContext.EventCallback
callback)
Registers a
CastReceiverContext.EventCallback
|
void | |
void |
sendMessage(String namespace,
String
senderId, String message)
Sends a message to a specific sender.
|
void |
setMessageReceivedListener(String namespace,
CastReceiverContext.MessageReceivedListener listener)
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 |
unregisterEventCallback(CastReceiverContext.EventCallback
callback)
Unregisters a
CastReceiverContext.EventCallback
|
Inherited Method Summary
Public Methods
public static CastReceiverContext getInstance ()
Returns the shared instance. Returns null
if the instance hasn't been
initialized.
public MediaManager getMediaManager ()
Returns the MediaManager
.
public CastReceiverOptions getReceiverOptions ()
Returns the receiver options.
public SenderInfo getSender (String senderId)
Returns the SenderInfo
with the given senderId
. Returns null
if not found.
public Collection<SenderInfo> getSenders ()
Returns all senders.
public static void initInstance (Context context)
Initializes the shared instance.
public void registerEventCallback (CastReceiverContext.EventCallback callback)
Registers a
CastReceiverContext.EventCallback
public void removeMessageReceivedListener (String namespace)
Removes a listener for a given namespace.
public void sendMessage (String namespace, String senderId, String message)
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, or null for broadcast to all senders |
message | the message |
public void setMessageReceivedListener (String namespace, CastReceiverContext.MessageReceivedListener listener)
Sets a listener for a given namespace.
Will replace a listener for the namespace if there is one.
public void start ()
Tells the Cast TV SDK that the receiver app has started and is ready to accept commands.
The MediaCommandCallback
and
CastReceiverContext.MessageReceivedListener
will be invoked if new messages
arrive.
public void stop ()
Tells the Cast TV SDK that the receiver app has stopped and won't accept commands any more.
The MediaCommandCallback
and
CastReceiverContext.MessageReceivedListener
will no longer be invoked.
public void unregisterEventCallback (CastReceiverContext.EventCallback callback)
Unregisters a
CastReceiverContext.EventCallback