Package com.castlabs.android.player

## Interface PlayerListener

- All Known Implementing Classes:
    `AbstractPlayerListener`, `MultiControllerPlaylist`, `PlaylistController`

      public interface PlayerListener

  This is a high level listener interface that provides callbacks for events from a video player.

  *NOTE* that all listener methods are invoked on the UI/main thread of your applications. You can directly interact with UI components from within the implementation of you listener.

  The SDK contains an `AbstractPlayerListener` implementation that you can use if you don't want to implement all the callbacks and are interested only in a subset of the available callbacks.
  Since:
    1.1.0

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `onDisplayChanged​(DisplayInfo displayInfo, boolean canPlay)` | Callback triggered when the underlying screen information changes.
    `void` | `onDurationChanged​(long durationUs)` | Callback triggered when the stream duration has been refreshed.
    `void` | `onError​(CastlabsPlayerException error)` | Error callback that is called when exceptions are raised on background threads.
    `void` | `onFatalErrorOccurred​(CastlabsPlayerException error)` | Error callback that is called when a fatal exception is raised on background threads.
    `void` | `onFullyBuffered()` | Invoked when all the remaining content has been buffered.
    `void` | `onPlaybackPositionChanged​(long playbackPositionMs)` | Event triggered when the playback position changed.
    `void` | `onPlayerModelChanged()` | Callback triggered when the player model has been changed and the `PlayerController` can now be queried for available and selected video tracks and qualities, audio tracks and subtitle tracks and the duration.
    `void` | `onSeekCompleted()` |
    `void` | `onSeekRangeChanged​(long startTimeMs, long endTimeMs)` | Event triggered when the seek range changed
    `void` | `onSeekTo​(long newPosition)` | This callback is invoked when the position of the video playback is actively changed by the `PlayerController`.
    `void` | `onSpeedChanged​(float speed)` | Callback triggered when the playback speed is changed.
    `void` | `onStateChanged​(PlayerController.State state)` | State change event triggered when the player state changed
    `void` | `onVideoKeyStatusChanged​(List<VideoTrackQuality> trackList)` | Callback triggered when video track's DRM-key status is changed
    `void` | `onVideoSizeChanged​(int width, int height, float pixelWidthHeightRatio)` | Invoked each time there's a change in the size of the video being rendered.

- - ### Method Detail

    - #### onFatalErrorOccurred

          void onFatalErrorOccurred​(@NonNull
                                    CastlabsPlayerException error)

      Error callback that is called when a fatal exception is raised on background threads. All Exceptions are wrapped in a `CastlabsPlayerException`. This method will be invoked *only* for fatal errors, and *before* the PlayerController is `released`. The `onError(CastlabsPlayerException)` method will be invoked after this one.
      Parameters:
        `error` - the player exception

    - #### onError

          void onError​(@NonNull
                       CastlabsPlayerException error)

      Error callback that is called when exceptions are raised on background threads. All Exceptions are wrapped in a `CastlabsPlayerException`. If the error is `fatal`, the PlayerController will be `released` right before this callback.
      Parameters:
        `error` - the player exception

    - #### onStateChanged

          void onStateChanged​(@NonNull
                              PlayerController.State state)

      State change event triggered when the player state changed
      Parameters:
        `state` - the new state

    - #### onSeekTo

          void onSeekTo​(long newPosition)

      This callback is invoked when the position of the video playback is actively changed by the `PlayerController`.
      Parameters:
        `newPosition` - the new position in microseconds

    - #### onSeekCompleted

          void onSeekCompleted()

    - #### onVideoSizeChanged

          void onVideoSizeChanged​(int width,
                                  int height,
                                  float pixelWidthHeightRatio)

      Invoked each time there's a change in the size of the video being rendered.
      Parameters:
        `width` - The video width in pixels.
        `height` - The video height in pixels.
        `pixelWidthHeightRatio` - The width to height ratio of each pixel. For the normal case of square pixels this will be equal to 1.0. Different values are indicative of anamorphic content.
      Since:
        3.0.0

    - #### onSeekRangeChanged

          void onSeekRangeChanged​(long startTimeMs,
                                  long endTimeMs)

      Event triggered when the seek range changed
      Parameters:
        `startTimeMs` - the possible seek start time in milliseconds
        `endTimeMs` - the possible seek end time in milliseconds

    - #### onPlaybackPositionChanged

          void onPlaybackPositionChanged​(long playbackPositionMs)

      Event triggered when the playback position changed. Note that for performance reasons, this is triggered at most once per second, hence you will only see when seconds changing during playback.
      Parameters:
        `playbackPositionMs` - the current playback position in milliseconds

    - #### onDisplayChanged

          void onDisplayChanged​(DisplayInfo displayInfo,
                                boolean canPlay)

      Callback triggered when the underlying screen information changes. This is triggered for example when a secondary display is connected. The passed `canPlay` parameter indicates weather playback can be resumed based on the current display and the secondary display configuration of the player controller (see `PlayerController.getSecondaryDisplay()`
      Parameters:
        `displayInfo` - the current display information
        `canPlay` - True if playback can be started or resumed with the current display configuration

    - #### onDurationChanged

          void onDurationChanged​(long durationUs)

      Callback triggered when the stream duration has been refreshed.
      Parameters:
        `durationUs` - Duration in microseconds

    - #### onSpeedChanged

          void onSpeedChanged​(float speed)

      Callback triggered when the playback speed is changed.
      Parameters:
        `speed` - Playback speed

    - #### onPlayerModelChanged

          void onPlayerModelChanged()

      Callback triggered when the player model has been changed and the `PlayerController` can now be queried for available and selected video tracks and qualities, audio tracks and subtitle tracks and the duration. The player model is changed every time upon the playback initial start-up or the media period change. Note that each time the player model changes, the video, audio, subtitle tracks and video quality are re-selected based on the parameters provided in `PlayerController.open(android.os.Bundle)` or via other `PlayerController` APIs. The callback is not triggered when the video, audio, subtitle tracks and video quality are selected by the application during playback using `PlayerController.setVideoTrack(VideoTrack)`, `PlayerController.setVideoQuality(VideoTrackQuality)`, `PlayerController.setAudioTrack(AudioTrack)` and `PlayerController.setSubtitleTrack(SubtitleTrack)`.

    - #### onVideoKeyStatusChanged

          void onVideoKeyStatusChanged​(@NonNull
                                       List<VideoTrackQuality> trackList)

      Callback triggered when video track's DRM-key status is changed
      Parameters:
        `trackList` - The list of tracks with changed key statuses
      Since:
        4.2.36

    - #### onFullyBuffered

          void onFullyBuffered()

      Invoked when all the remaining content has been buffered. From this point onwards no more network activity is required to finish playing the current media.
      Since:
        4.2.1