Package com.google.android.exoplayer2

## Interface Player.EventListener

- All Known Subinterfaces:
    `Player.Listener`
  All Known Implementing Classes:
    `AnalyticsCollector`, `DebugTextViewHelper`, `ExoPlayerTestRunner`, `ImaAdsLoader`
  Enclosing interface:
    Player

      @Deprecated
      public static interface Player.EventListener

  Deprecated.
  Use `Player.Listener`.
  Listener of changes in player state.

  All methods have no-op default implementations to allow selective overrides.

  Listeners can choose to implement individual events (e.g. `onIsPlayingChanged(boolean)`) or `onEvents(Player, Events)`, which is called after one or more events occurred together.

- - ### Method Summary

    All Methods Instance Methods Default Methods Deprecated Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `default void` | `onAvailableCommandsChanged​(Player.Commands availableCommands)` | Deprecated. Called when the value returned from `Player.isCommandAvailable(int)` changes for at least one `Player.Command`.
    `default void` | `onEvents​(Player player, Player.Events events)` | Deprecated. Called when one or more player states changed.
    `default void` | `onIsLoadingChanged​(boolean isLoading)` | Deprecated. Called when the player starts or stops loading the source.
    `default void` | `onIsPlayingChanged​(boolean isPlaying)` | Deprecated. Called when the value of `Player.isPlaying()` changes.
    `default void` | `onLoadingChanged​(boolean isLoading)` | Deprecated. Use `onIsLoadingChanged(boolean)` instead.
    `default void` | `onMediaItemTransition​(MediaItem mediaItem, int reason)` | Deprecated. Called when playback transitions to a media item or starts repeating a media item according to the current `repeat mode`.
    `default void` | `onMediaMetadataChanged​(MediaMetadata mediaMetadata)` | Deprecated. Called when the combined `MediaMetadata` changes.
    `default void` | `onPlaybackParametersChanged​(PlaybackParameters playbackParameters)` | Deprecated. Called when the current playback parameters change.
    `default void` | `onPlaybackStateChanged​(int state)` | Deprecated. Called when the value returned from `Player.getPlaybackState()` changes.
    `default void` | `onPlaybackSuppressionReasonChanged​(int playbackSuppressionReason)` | Deprecated. Called when the value returned from `Player.getPlaybackSuppressionReason()` changes.
    `default void` | `onPlayerError​(ExoPlaybackException error)` | Deprecated. Called when an error occurs.
    `default void` | `onPlayerStateChanged​(boolean playWhenReady, int playbackState)` | Deprecated. Use `onPlaybackStateChanged(int)` and `onPlayWhenReadyChanged(boolean, int)` instead.
    `default void` | `onPlayWhenReadyChanged​(boolean playWhenReady, int reason)` | Deprecated. Called when the value returned from `Player.getPlayWhenReady()` changes.
    `default void` | `onPositionDiscontinuity​(int reason)` | Deprecated. Use `onPositionDiscontinuity(PositionInfo, PositionInfo, int)` instead.
    `default void` | `onPositionDiscontinuity​(Player.PositionInfo oldPosition, Player.PositionInfo newPosition, int reason)` | Deprecated. Called when a position discontinuity occurs.
    `default void` | `onRepeatModeChanged​(int repeatMode)` | Deprecated. Called when the value of `Player.getRepeatMode()` changes.
    `default void` | `onSeekProcessed()` | Deprecated. Seeks are processed without delay.
    `default void` | `onShuffleModeEnabledChanged​(boolean shuffleModeEnabled)` | Deprecated. Called when the value of `Player.getShuffleModeEnabled()` changes.
    `default void` | `onStaticMetadataChanged​(List<Metadata> metadataList)` | Deprecated. Called when the static metadata changes.
    `default void` | `onTimelineChanged​(Timeline timeline, int reason)` | Deprecated. Called when the timeline has been refreshed.
    `default void` | `onTimelineChanged​(Timeline timeline, Object manifest, int reason)` | Deprecated. Use `onTimelineChanged(Timeline, int)` instead.
    `default void` | `onTracksChanged​(TrackGroupArray trackGroups, TrackSelectionArray trackSelections)` | Deprecated. Called when the available or selected tracks change.

- - ### Method Detail

    - #### onTimelineChanged

          default void onTimelineChanged​(Timeline timeline,
                                         @TimelineChangeReason
                                         int reason)

      Deprecated.
      Called when the timeline has been refreshed.

      Note that the current window or period index may change as a result of a timeline change. If playback can't continue smoothly because of this timeline change, a separate `onPositionDiscontinuity(PositionInfo, PositionInfo, int)` callback will be triggered.

      `onEvents(Player, Events)` will also be called to report this event along with other events that happen in the same `Looper` message queue iteration.

      Parameters:
        `timeline` - The latest timeline. Never null, but may be empty.
        `reason` - The `Player.TimelineChangeReason` responsible for this timeline change.

    - #### onTimelineChanged

          @Deprecated
          default void onTimelineChanged​(Timeline timeline,
                                         @Nullable
                                         Object manifest,
                                         @TimelineChangeReason
                                         int reason)

      Deprecated.
      Use `onTimelineChanged(Timeline, int)` instead. The manifest can be accessed by using `Player.getCurrentManifest()` or `timeline.getWindow(windowIndex, window).manifest` for a given window index.

    - #### onMediaItemTransition

          default void onMediaItemTransition​(@Nullable
                                             MediaItem mediaItem,
                                             @MediaItemTransitionReason
                                             int reason)

      Deprecated.
      Called when playback transitions to a media item or starts repeating a media item according to the current `repeat mode`.

      Note that this callback is also called when the playlist becomes non-empty or empty as a consequence of a playlist change.

      `onEvents(Player, Events)` will also be called to report this event along with other events that happen in the same `Looper` message queue iteration.

      Parameters:
        `mediaItem` - The `MediaItem`. May be null if the playlist becomes empty.
        `reason` - The reason for the transition.

    - #### onTracksChanged

          default void onTracksChanged​(TrackGroupArray trackGroups,
                                       TrackSelectionArray trackSelections)

      Deprecated.
      Called when the available or selected tracks change.

      `onEvents(Player, Events)` will also be called to report this event along with other events that happen in the same `Looper` message queue iteration.

      Parameters:
        `trackGroups` - The available tracks. Never null, but may be of length zero.
        `trackSelections` - The selected tracks. Never null, but may contain null elements. A concrete implementation may include null elements if it has a fixed number of renderer components, wishes to report a TrackSelection for each of them, and has one or more renderer components that is not assigned any selected tracks.

    - #### onStaticMetadataChanged

          default void onStaticMetadataChanged​(List<Metadata> metadataList)

      Deprecated.
      Called when the static metadata changes.

      The provided `metadataList` is an immutable list of `Metadata` instances, where the elements correspond to the `current track selections`, or an empty list if there are no track selections or the selected tracks contain no static metadata.

      The metadata is considered static in the sense that it comes from the tracks' declared Formats, rather than being timed (or dynamic) metadata, which is represented within a metadata track.

      `onEvents(Player, Events)` will also be called to report this event along with other events that happen in the same `Looper` message queue iteration.

      Parameters:
        `metadataList` - The static metadata.

    - #### onMediaMetadataChanged

          default void onMediaMetadataChanged​(MediaMetadata mediaMetadata)

      Deprecated.
      Called when the combined `MediaMetadata` changes.

      The provided `MediaMetadata` is a combination of the `MediaItem.mediaMetadata` and the static and dynamic metadata sourced from `onStaticMetadataChanged(List)` and `MetadataOutput.onMetadata(Metadata)`.

      `onEvents(Player, Events)` will also be called to report this event along with other events that happen in the same `Looper` message queue iteration.

      Parameters:
        `mediaMetadata` - The combined `MediaMetadata`.

    - #### onIsLoadingChanged

          default void onIsLoadingChanged​(boolean isLoading)

      Deprecated.
      Called when the player starts or stops loading the source.

      `onEvents(Player, Events)` will also be called to report this event along with other events that happen in the same `Looper` message queue iteration.

      Parameters:
        `isLoading` - Whether the source is currently being loaded.

    - #### onLoadingChanged

          @Deprecated
          default void onLoadingChanged​(boolean isLoading)

      Deprecated.
      Use `onIsLoadingChanged(boolean)` instead.

    - #### onAvailableCommandsChanged

          default void onAvailableCommandsChanged​(Player.Commands availableCommands)

      Deprecated.
      Called when the value returned from `Player.isCommandAvailable(int)` changes for at least one `Player.Command`.

      `onEvents(Player, Events)` will also be called to report this event along with other events that happen in the same `Looper` message queue iteration.

      Parameters:
        `availableCommands` - The available `Player.Commands`.

    - #### onPlayerStateChanged

          @Deprecated
          default void onPlayerStateChanged​(boolean playWhenReady,
                                            @State
                                            int playbackState)

      Deprecated.
      Use `onPlaybackStateChanged(int)` and `onPlayWhenReadyChanged(boolean, int)` instead.

    - #### onPlaybackStateChanged

          default void onPlaybackStateChanged​(@State
                                              int state)

      Deprecated.
      Called when the value returned from `Player.getPlaybackState()` changes.

      `onEvents(Player, Events)` will also be called to report this event along with other events that happen in the same `Looper` message queue iteration.

      Parameters:
        `state` - The new playback `state`.

    - #### onPlayWhenReadyChanged

          default void onPlayWhenReadyChanged​(boolean playWhenReady,
                                              @PlayWhenReadyChangeReason
                                              int reason)

      Deprecated.
      Called when the value returned from `Player.getPlayWhenReady()` changes.

      `onEvents(Player, Events)` will also be called to report this event along with other events that happen in the same `Looper` message queue iteration.

      Parameters:
        `playWhenReady` - Whether playback will proceed when ready.
        `reason` - The `reason` for the change.

    - #### onPlaybackSuppressionReasonChanged

          default void onPlaybackSuppressionReasonChanged​(@PlaybackSuppressionReason
                                                          int playbackSuppressionReason)

      Deprecated.
      Called when the value returned from `Player.getPlaybackSuppressionReason()` changes.

      `onEvents(Player, Events)` will also be called to report this event along with other events that happen in the same `Looper` message queue iteration.

      Parameters:
        `playbackSuppressionReason` - The current `Player.PlaybackSuppressionReason`.

    - #### onIsPlayingChanged

          default void onIsPlayingChanged​(boolean isPlaying)

      Deprecated.
      Called when the value of `Player.isPlaying()` changes.

      `onEvents(Player, Events)` will also be called to report this event along with other events that happen in the same `Looper` message queue iteration.

      Parameters:
        `isPlaying` - Whether the player is playing.

    - #### onRepeatModeChanged

          default void onRepeatModeChanged​(@RepeatMode
                                           int repeatMode)

      Deprecated.
      Called when the value of `Player.getRepeatMode()` changes.

      `onEvents(Player, Events)` will also be called to report this event along with other events that happen in the same `Looper` message queue iteration.

      Parameters:
        `repeatMode` - The `Player.RepeatMode` used for playback.

    - #### onShuffleModeEnabledChanged

          default void onShuffleModeEnabledChanged​(boolean shuffleModeEnabled)

      Deprecated.
      Called when the value of `Player.getShuffleModeEnabled()` changes.

      `onEvents(Player, Events)` will also be called to report this event along with other events that happen in the same `Looper` message queue iteration.

      Parameters:
        `shuffleModeEnabled` - Whether shuffling of windows is enabled.

    - #### onPlayerError

          default void onPlayerError​(ExoPlaybackException error)

      Deprecated.
      Called when an error occurs. The playback state will transition to `Player.STATE_IDLE` immediately after this method is called. The player instance can still be used, and `Player.release()` must still be called on the player should it no longer be required.

      `onEvents(Player, Events)` will also be called to report this event along with other events that happen in the same `Looper` message queue iteration.

      Parameters:
        `error` - The error.

    - #### onPositionDiscontinuity

          @Deprecated
          default void onPositionDiscontinuity​(@DiscontinuityReason
                                               int reason)

      Deprecated.
      Use `onPositionDiscontinuity(PositionInfo, PositionInfo, int)` instead.

    - #### onPositionDiscontinuity

          default void onPositionDiscontinuity​(Player.PositionInfo oldPosition,
                                               Player.PositionInfo newPosition,
                                               @DiscontinuityReason
                                               int reason)

      Deprecated.
      Called when a position discontinuity occurs.

      A position discontinuity occurs when the playing period changes, the playback position jumps within the period currently being played, or when the playing period has been skipped or removed.

      `onEvents(Player, Events)` will also be called to report this event along with other events that happen in the same `Looper` message queue iteration.

      Parameters:
        `oldPosition` - The position before the discontinuity.
        `newPosition` - The position after the discontinuity.
        `reason` - The `Player.DiscontinuityReason` responsible for the discontinuity.

    - #### onPlaybackParametersChanged

          default void onPlaybackParametersChanged​(PlaybackParameters playbackParameters)

      Deprecated.
      Called when the current playback parameters change. The playback parameters may change due to a call to `Player.setPlaybackParameters(PlaybackParameters)`, or the player itself may change them (for example, if audio playback switches to passthrough or offload mode, where speed adjustment is no longer possible).

      `onEvents(Player, Events)` will also be called to report this event along with other events that happen in the same `Looper` message queue iteration.

      Parameters:
        `playbackParameters` - The playback parameters.

    - #### onSeekProcessed

          @Deprecated
          default void onSeekProcessed()

      Deprecated.
      Seeks are processed without delay. Listen to `onPositionDiscontinuity(PositionInfo, PositionInfo, int)` with reason `Player.DISCONTINUITY_REASON_SEEK` instead.

    - #### onEvents

          default void onEvents​(Player player,
                                Player.Events events)

      Deprecated.
      Called when one or more player states changed.

      State changes and events that happen within one `Looper` message queue iteration are reported together and only after all individual callbacks were triggered.

      Listeners should prefer this method over individual callbacks in the following cases:

      - They intend to trigger the same logic for multiple events (e.g. when updating a UI for both `onPlaybackStateChanged(int)` and `onPlayWhenReadyChanged(boolean, int)`).
      - They need access to the `Player` object to trigger further events (e.g. to call `Player.seekTo(long)` after a `onMediaItemTransition(MediaItem, int)`).
      - They intend to use multiple state values together or in combination with `Player` getter methods. For example using `Player.getCurrentWindowIndex()` with the `timeline` provided in `onTimelineChanged(Timeline, int)` is only safe from within this method.
      - They are interested in events that logically happened together (e.g `onPlaybackStateChanged(int)` to `Player.STATE_BUFFERING` because of `onMediaItemTransition(MediaItem, int)`).
      Parameters:
        `player` - The `Player` whose state changed. Use the getters to obtain the latest states.
        `events` - The `Player.Events` that happened in this iteration, indicating which player states changed.