CaaS

object CaaS

CaaS (Cast as a Service) will handle the CastContext. It is recommend to access cast-related operations via CaaS. CaaS provides setup function to initialize media route button, and cast function to load content to google cast device.

Functions

Link copied to clipboard
@JvmStatic
fun addListener(castEventListener: CastEventListener)

Setup CaaSSessionManagerListener and CaaSRemoteClientCallback. Remember to call removeListener or may cause memory leak and other errors.

Link copied to clipboard
@JvmStatic
fun cast(castOptions: CastOptions, onLoad: (MediaLoadRequestData.Builder) -> MediaLoadRequestData.Builder? = null)

Cast content to receiver, and setup mini controller. This function will not cast the content if already casted.

@JvmStatic
fun cast(list: List<CastOptions>, startIndex: Int = 0, onLoad: (MediaLoadRequestData.Builder) -> MediaLoadRequestData.Builder? = null)

Cast multiple contents to receiver at once. This function will not cast the start content if already casted or invalided index.

Link copied to clipboard
@JvmStatic
fun endCurrentSession(stopCasting: Boolean)

Finish current casting session

Link copied to clipboard
fun getMediaInfo(): MediaInfo?
Link copied to clipboard
fun getReceiverName(): String?
Link copied to clipboard
@JvmStatic
fun isCasting(): Boolean

Show it is casting or not.

Link copied to clipboard
@JvmStatic
fun isConnected(): Boolean

Show the google cast is connected or not.

Link copied to clipboard
@JvmStatic
fun removeListener(castEventListener: CastEventListener)

Remove CaaSSessionManageListener and CaaSRemoteClientCallback. If called addListener, remember to call this function to prevent from memory leak.

Link copied to clipboard
@JvmStatic
fun seekTo(positionMs: Long)

Seek to the specified position in milliseconds if valid cast session exists.

Link copied to clipboard
fun setRemoteIdleImage(imageUrl: String)
Link copied to clipboard
@JvmStatic
fun setup(context: Context, button: MediaRouteButton): Boolean
@JvmStatic
fun setup(context: Context, menu: Menu, @IdRes castId: Int): Boolean

Setup the CastContext and MediaRouteButton, return true if success, otherwise false.