CastManager

class CastManager(appContext: Context, logger: Logger = defaultCastLogger)

CastManager uses Google Cast Application Framework's (CAF) SessionManager instance to manage CastSession and coordinate all the Cast interactions. CastManager manages, internally, a custom media channel to facilitate communication between the Sender and the Receiver Applications. CastManager also provides access to CastPlayer, for playing the content on the Web Receiver Application, and enforces policies for accessing Firstlight Platform resources.

Initialization:

--------------

CastManager is using CAF's framework global singleton object, the CastContext, which coordinates all the Cast interactions. The Sender Application must implement the com.google.android.gms.cast.framework.OptionsProvider interface to supply CastOptions needed to initialize the CastContext singleton. The most important option is the Receiver Application ID, which is used to filter Cast Device discovery results and to launch the Receiver Application when a Cast Session is started. When the CastManager instance is created the Sender Application MUST also register CastManagerStateListener that provides notifications for the CastManager and CAF's Cast Session events.

Cast Session Management:

-----------------------

For the Cast framework a Cast Session combines the steps of connecting to a device, launching (or joining), connecting to a Receiver Application, and initializing a media control channel if appropriate. The media control channel is how the Cast framework sends and receives messages from the Receiver Media Player. The Cast Session will be started automatically, when user clicks the Cast button and selects a device from the list, and will be stopped automatically when user disconnects. Reconnecting to a receiver session due to networking issues is also automatically handled by the Cast SDK.

Casting (playing content on the web receiver application):

---------------------------------------------------------

The Sender Application requires CastPlayer instance to initiate content playback, but before casting any media, the Cast Device MUST be registered with Firstlight Platform. The Sender Application should call registerUserData to perform the user data, that includes the Cast Device ID, registration. The registration should be done just after CastManager notifies the Sender Application that the Cast Session has be started. After the user data registration the Sender Application should proceed with loading media on the Receiver Application. If the user data registration failed then the Sender Application will be notified, with an error, when the first attempt is made to load media on the Receiver Application.

Constructors

Link copied to clipboard
constructor(appContext: Context, logger: Logger = defaultCastLogger)

Creates CastManager instance

Properties

Link copied to clipboard
var castContext: CastContext?
Link copied to clipboard
val castOptions: CastOptions
Link copied to clipboard

Functions

Link copied to clipboard

Triggers release of all underlying resources held by this CastManager irrespective of the state it is in.

Link copied to clipboard
Link copied to clipboard
fun registerUserData(platformClient: PlatformClient, castDeviceID: String, authToken: String)

Registers, with Platform Services, the data pertaining to the user authentication token, and both the mobile and the cast device information.

Link copied to clipboard

Uses a custom channel to send messages to the Receiver Application.