SessionAvailabilityListener


@UnstableApi
public interface SessionAvailabilityListener


Listener of changes in the cast session availability.

Summary

Nested types

Reasons for the Cast session becoming unavailable.

Constants

default static final int

The Cast receiver application was stopped.

default static final int

The Cast session was disconnected.

default static final int

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

default static final int

The user explicitly stopped casting.

Public methods

abstract void

Called when a cast session becomes available to the player.

abstract void

Called when the cast session becomes unavailable.

default void

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

Constants

SESSION_UNAVAILABLE_REASON_APP_STOPPED

default static final int SESSION_UNAVAILABLE_REASON_APP_STOPPED = 3

The Cast receiver application was stopped.

SESSION_UNAVAILABLE_REASON_DISCONNECTED

default static final int SESSION_UNAVAILABLE_REASON_DISCONNECTED = 4

The Cast session was disconnected.

SESSION_UNAVAILABLE_REASON_ROUTE_CHANGED

default static final int SESSION_UNAVAILABLE_REASON_ROUTE_CHANGED = 1

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

SESSION_UNAVAILABLE_REASON_STOPPED

default static final int SESSION_UNAVAILABLE_REASON_STOPPED = 2

The user explicitly stopped casting.

Public methods

onCastSessionAvailable

abstract void onCastSessionAvailable()

Called when a cast session becomes available to the player.

onCastSessionUnavailable

abstract void onCastSessionUnavailable()

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

onCastSessionUnavailable

default void onCastSessionUnavailable(
    @SessionAvailabilityListener.SessionUnavailableReason int reason
)

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.