The behavior of this class depends on the underlying Cast session, which is obtained from the - * Cast context passed to {@link #CastPlayer}. To keep track of the session, - * {@link #isCastSessionAvailable()} can be queried and {@link SessionAvailabilityListener} can be - * implemented and attached to the player.
- * - *If no session is available, the player state will remain unchanged and calls to methods that - * alter it will be ignored. Querying the player state is possible even when no session is - * available, in which case, the last observed receiver app state is reported.
- * - *Methods should be called on the application's main thread.
- */ -public final class CastPlayer implements Player { - - /** - * Listener of changes in the cast session availability. - */ - public interface SessionAvailabilityListener { - - /** - * Called when a cast session becomes available to the player. - */ - void onCastSessionAvailable(); - - /** - * Called when the cast session becomes unavailable. - */ - void onCastSessionUnavailable(); - - } - - private static final String TAG = "CastPlayer"; - - private static final int RENDERER_COUNT = 3; - private static final int RENDERER_INDEX_VIDEO = 0; - private static final int RENDERER_INDEX_AUDIO = 1; - private static final int RENDERER_INDEX_TEXT = 2; - private static final long PROGRESS_REPORT_PERIOD_MS = 1000; - private static final TrackGroupArray EMPTY_TRACK_GROUP_ARRAY = new TrackGroupArray(); - private static final TrackSelectionArray EMPTY_TRACK_SELECTION_ARRAY = - new TrackSelectionArray(null, null, null); - private static final long[] EMPTY_TRACK_ID_ARRAY = new long[0]; - - private final CastContext castContext; - private final Timeline.Window window; - private final Timeline.Period period; - - private RemoteMediaClient remoteMediaClient; - - // Result callbacks. - private final StatusListener statusListener; - private final SeekResultCallback seekResultCallback; - - // Listeners. - private final CopyOnWriteArraySet