Interface Player.Listener

    • Method Detail

      • onTimelineChanged

        default void onTimelineChanged​(Timeline timeline,
                                       @TimelineChangeReason
                                       @com.google.android.exoplayer2.Player.TimelineChangeReason int reason)
        Called when the timeline has been refreshed.

        Note that the current MediaItem or playback position 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
                                           @com.google.android.exoplayer2.Player.MediaItemTransitionReason int reason)
        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​(Tracks tracks)
        Called when the 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:
        tracks - The available tracks information. Never null, but may be of length zero.
      • onMediaMetadataChanged

        default void onMediaMetadataChanged​(MediaMetadata mediaMetadata)
        Called when the combined MediaMetadata changes.

        The provided MediaMetadata is a combination of the MediaItem metadata, the static metadata in the media's Format, and any timed metadata that has been parsed from the media and output via onMetadata(Metadata). If a field is populated in the MediaItem.mediaMetadata, it will be prioritised above the same field coming from static or timed metadata.

        This method may be called multiple times in quick succession.

        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)
        Called when the playlist MediaMetadata 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.

      • onIsLoadingChanged

        default void onIsLoadingChanged​(boolean isLoading)
        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.
      • onPlaybackStateChanged

        default void onPlaybackStateChanged​(@State
                                            @com.google.android.exoplayer2.Player.State int playbackState)
        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
                                            @com.google.android.exoplayer2.Player.PlayWhenReadyChangeReason int reason)
        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.
      • onIsPlayingChanged

        default void onIsPlayingChanged​(boolean isPlaying)
        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
                                         @com.google.android.exoplayer2.Player.RepeatMode int repeatMode)
        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)
        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 media items is enabled.
      • onPlayerError

        default void onPlayerError​(PlaybackException error)
        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)
        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

        default void onPositionDiscontinuity​(Player.PositionInfo oldPosition,
                                             Player.PositionInfo newPosition,
                                             @DiscontinuityReason
                                             @com.google.android.exoplayer2.Player.DiscontinuityReason int reason)
        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)
        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)
        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)
        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​(long maxSeekToPreviousPositionMs)
        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.
      • onAudioSessionIdChanged

        default void onAudioSessionIdChanged​(int audioSessionId)
        Called when the audio session ID 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:
        audioSessionId - The audio session ID.
      • onAudioAttributesChanged

        default void onAudioAttributesChanged​(AudioAttributes audioAttributes)
        Called when the audio attributes 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:
        audioAttributes - The audio attributes.
      • onVolumeChanged

        default void onVolumeChanged​(float volume)
        Called when the volume 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:
        volume - The new volume, with 0 being silence and 1 being unity gain.
      • onSkipSilenceEnabledChanged

        default void onSkipSilenceEnabledChanged​(boolean skipSilenceEnabled)
        Called when skipping silences is enabled or disabled in the audio stream.

        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:
        skipSilenceEnabled - Whether skipping silences in the audio stream is enabled.
      • onDeviceInfoChanged

        default void onDeviceInfoChanged​(DeviceInfo deviceInfo)
        Called when the device information 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:
        deviceInfo - The new DeviceInfo.
      • onDeviceVolumeChanged

        default void onDeviceVolumeChanged​(int volume,
                                           boolean muted)
        Called when the device volume or mute state 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:
        volume - The new device volume, with 0 being silence and 1 being unity gain.
        muted - Whether the device is muted.
      • onVideoSizeChanged

        default void onVideoSizeChanged​(VideoSize videoSize)
        Called each time there's a change in the size of the video being rendered.

        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:
        videoSize - The new size of the video.
      • onSurfaceSizeChanged

        default void onSurfaceSizeChanged​(int width,
                                          int height)
        Called each time there's a change in the size of the surface onto which the video is being rendered.

        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:
        width - The surface width in pixels. May be C.LENGTH_UNSET if unknown, or 0 if the video is not rendered onto a surface.
        height - The surface height in pixels. May be C.LENGTH_UNSET if unknown, or 0 if the video is not rendered onto a surface.
      • onRenderedFirstFrame

        default void onRenderedFirstFrame()
        Called when a frame is rendered for the first time since setting the surface, or since the renderer was reset, or since the stream being rendered was changed.

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

      • onCues

        default void onCues​(CueGroup cueGroup)
        Called when there is a change in the CueGroup.

        Both onCues(List) and onCues(CueGroup) are called when there is a change in the cues. You should only implement one or the other.

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

      • onMetadata

        default void onMetadata​(Metadata metadata)
        Called when there is metadata associated with the current playback time.

        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:
        metadata - The metadata.