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` | `onMaxSeekToPreviousPositionChanged​(int maxSeekToPreviousPositionMs)` | Deprecated. Called when the value of `Player.getMaxSeekToPreviousPosition()` changes.
    `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 playbackState)` | 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​(PlaybackException error)` | Deprecated. Called when an error occurs.
    `default void` | `onPlayerErrorChanged​(PlaybackException error)` | Deprecated. Called when the `PlaybackException` returned by `Player.getPlayerError()` changes.
    `default void` | `onPlayerStateChanged​(boolean playWhenReady, int playbackState)` | Deprecated. Use `onPlaybackStateChanged(int)` and `onPlayWhenReadyChanged(boolean, int)` instead.
    `default void` | `onPlaylistMetadataChanged​(MediaMetadata mediaMetadata)` | Deprecated. Called when the playlist `MediaMetadata` changes.
    `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` | `onSeekBackIncrementChanged​(long seekBackIncrementMs)` | Deprecated. Called when the value of `Player.getSeekBackIncrement()` changes.
    `default void` | `onSeekForwardIncrementChanged​(long seekForwardIncrementMs)` | Deprecated. Called when the value of `Player.getSeekForwardIncrement()` 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. Use `Player.getMediaMetadata()` and `onMediaMetadataChanged(MediaMetadata)` for access to structured metadata, or access the raw static metadata directly from the `track selections' formats`.
    `default void` | `onTimelineChanged​(Timeline timeline, int reason)` | Deprecated. Called when the timeline has been refreshed.
    `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.

    - #### 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

          @Deprecated
          default void onStaticMetadataChanged​(List<Metadata> metadataList)

      Deprecated.
      Use `Player.getMediaMetadata()` and `onMediaMetadataChanged(MediaMetadata)` for access to structured metadata, or access the raw static metadata directly from the `track selections' formats`.

    - #### 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 from the `track selections' formats` 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`.

    - #### onPlaylistMetadataChanged

          default void onPlaylistMetadataChanged​(MediaMetadata mediaMetadata)

      Deprecated.
      Called when the playlist `MediaMetadata` changes.

    - #### 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 playbackState)

      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:
        `playbackState` - 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​(PlaybackException 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.

      Implementations of Player may pass an instance of a subclass of `PlaybackException` to this method in order to include more information about the error.

      Parameters:
        `error` - The error.

    - #### onPlayerErrorChanged

          default void onPlayerErrorChanged​(@Nullable
                                            PlaybackException error)

      Deprecated.
      Called when the `PlaybackException` returned by `Player.getPlayerError()` 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.

      Implementations of Player may pass an instance of a subclass of `PlaybackException` to this method in order to include more information about the error.

      Parameters:
        `error` - The new error, or null if the error is being cleared.

    - #### 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.

    - #### onSeekBackIncrementChanged

          default void onSeekBackIncrementChanged​(long seekBackIncrementMs)

      Deprecated.
      Called when the value of `Player.getSeekBackIncrement()` 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:
        `seekBackIncrementMs` - The `Player.seekBack()` increment, in milliseconds.

    - #### onSeekForwardIncrementChanged

          default void onSeekForwardIncrementChanged​(long seekForwardIncrementMs)

      Deprecated.
      Called when the value of `Player.getSeekForwardIncrement()` 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:
        `seekForwardIncrementMs` - The `Player.seekForward()` increment, in milliseconds.

    - #### onMaxSeekToPreviousPositionChanged

          default void onMaxSeekToPreviousPositionChanged​(int maxSeekToPreviousPositionMs)

      Deprecated.
      Called when the value of `Player.getMaxSeekToPreviousPosition()` 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:
        `maxSeekToPreviousPositionMs` - The maximum position for which `Player.seekToPrevious()` seeks to the previous position, in milliseconds.

    - #### 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.

      Only state changes represented by `events` are reported through this method.

      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.