SessionAvailabilityListener


@UnstableApi
interface SessionAvailabilityListener


Listener of changes in the cast session availability.

Summary

Nested types

Reasons for the Cast session becoming unavailable.

Constants

const Int

The Cast receiver application was stopped.

const Int

The Cast session was disconnected.

const Int

Playback is transferring to the local device because the route was changed.

const Int

The user explicitly stopped casting.

Public functions

Unit

Called when a cast session becomes available to the player.

Unit

Called when the cast session becomes unavailable.

Unit

Called when the cast session becomes unavailable with the specified reason.

Constants

SESSION_UNAVAILABLE_REASON_APP_STOPPED

const val SESSION_UNAVAILABLE_REASON_APP_STOPPED = 3: Int

The Cast receiver application was stopped.

SESSION_UNAVAILABLE_REASON_DISCONNECTED

const val SESSION_UNAVAILABLE_REASON_DISCONNECTED = 4: Int

The Cast session was disconnected.

SESSION_UNAVAILABLE_REASON_ROUTE_CHANGED

const val SESSION_UNAVAILABLE_REASON_ROUTE_CHANGED = 1: Int

Playback is transferring to the local device because the route was changed.

SESSION_UNAVAILABLE_REASON_STOPPED

const val SESSION_UNAVAILABLE_REASON_STOPPED = 2: Int

The user explicitly stopped casting.

Public functions

onCastSessionAvailable

fun onCastSessionAvailable(): Unit

Called when a cast session becomes available to the player.

onCastSessionUnavailable

fun onCastSessionUnavailable(): Unit

Called when the cast session becomes unavailable. This only gets called if onCastSessionUnavailable(@CastPlayer.CastSessionChangeReason int reason) is not implemented

onCastSessionUnavailable

fun onCastSessionUnavailable(
    @SessionAvailabilityListener.SessionUnavailableReason reason: Int
): Unit

Called when the cast session becomes unavailable with the specified reason. The reason can affect the player state transfer. For example, a "Stop Casting" button press or a disconnection typically require the playback to pause.