Package com.castlabs.android.player

## Class ExtendedTrackSelector

- java.lang.Object
- - com.google.android.exoplayer2.trackselection.TrackSelector
  - - com.castlabs.android.player.ExtendedTrackSelector

- All Implemented Interfaces:
    `DrmEventListener`

      public class ExtendedTrackSelector
      extends com.google.android.exoplayer2.trackselection.TrackSelector
      implements DrmEventListener

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class | Description
    --- | --- | ---
    `static interface` | `ExtendedTrackSelector.EventListener` | Interface which receives Track Selection-related callbacks.
    `class` | `ExtendedTrackSelector.ModelSelection` |
    `static interface` | `ExtendedTrackSelector.PlayerInfoProvider` |

    - ### Nested classes/interfaces inherited from class com.google.android.exoplayer2.trackselection.TrackSelector

      `com.google.android.exoplayer2.trackselection.TrackSelector.InvalidationListener`

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `ExtendedTrackSelector()` |
    `ExtendedTrackSelector​(com.castlabs.android.player.VideoTrackSelection.Factory videoTrackSelectionFactory, ExtendedTrackSelector.PlayerInfoProvider playerInfoProvider, ExtendedTrackSelector.EventListener eventListener, PlayerConfig playerConfig)` |

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `ExtendedTrackSelector.ModelSelection` | `createModel​(com.google.android.exoplayer2.trackselection.TrackSelectorResult trackSelectorResult)` |
    `static void` | `extractDashThumbnails​(com.google.android.exoplayer2.source.dash.manifest.DashManifest dashManifest, com.google.android.exoplayer2.Timeline timeline, PlayerModel playerModel)` | Extracts the embedded thumbnail tracks in the DASH manifest, and updates the provided player model with them.
    `String` | `getPreferredAudioLanguage()` | Get the preferred audio language
    `String` | `getPreferredSubtitleLanguage()` | Get the preferred subtitles language
    `void` | `onLicenseKeysChanged()` | Called when keys are changed e.g.
    `void` | `onLicenseKeysLoaded()` | Called when a key was loaded successfully
    `void` | `onLicenseLoadError​(int currentAttempt, int maxAttempts, DownloadException downloadException)` | Called when license load error occurred
    `void` | `onSelectionActivated​(Object info)` |
    `com.google.android.exoplayer2.trackselection.TrackSelectorResult` | `selectTracks​(com.google.android.exoplayer2.RendererCapabilities[] rendererCapabilities, com.google.android.exoplayer2.source.TrackGroupArray trackGroups, com.google.android.exoplayer2.source.MediaSource.MediaPeriodId periodId, com.google.android.exoplayer2.Timeline timeline, Object manifest)` |
    `void` | `setAudioTrackIndexOverride​(TrackIndexOverride trackIndexOverride)` | Set audio track indices override to be used during audio selection
    `void` | `setAudioTrackOverride​(AudioTrack audioTrack)` | Set audio track override to be used during audio selection
    `void` | `setDisabledRendererIndices​(List<Integer> disabledRendererIndices)` | Disable renderers by indices such that the tracks of the corresponding type will not be selected
    `void` | `setDisplaySize​(Point size)` |
    `void` | `setInitialVideoTrackGroupIndex​(int initialVideoTrackGroupIndex)` | Set video track group index override to be used during video selection.
    `void` | `setPreselectedAudio​(List<TrackIndexOverride> preselectedAudio)` | Preselect audio tracks available for the selection
    `void` | `setPreselectedSideloadedTracks​(List<SubtitleTrack> sideloadedTracks)` | Preselect sideloaded subtitle tracks available for the selection
    `void` | `setPreselectedSubtitle​(List<TrackIndexOverride> preselectedSubtitle)` | Preselect subtitle tracks available for the selection
    `void` | `setPreselectedVideoQualities​(int[] preselectedVideoQualityIndices)` | Preselect video qualities available for the selection
    `void` | `setSubtitleTrackIndexOverride​(TrackIndexOverride trackIndexOverride)` | Set subtitle track indices override to be used during subtitle selection
    `void` | `setSubtitleTrackOverride​(SubtitleTrack subtitleTrack)` | Set subtitle track override to be used during subtitle selection
    `void` | `setVideoCodecFilter​(int videoCodecFilter)` | Set the video codec filtering policy, one of `SdkConsts.VideoCodecFilter`.
    `void` | `setVideoFilter​(VideoFilterConfiguration contentFilter, VideoFilterConfiguration adsFilter)` | Sets the video filter for content and ads.
    `void` | `setVideoHdEnabled​(boolean isHdPlaybackEnabled)` | Enable or disable the video HD tracks.
    `void` | `setVideoMaxResolution​(int maxVideoWidth, int maxVideoHeight)` | Set the max video tracks resolution in pixels such that the video tracks with higher resolutions will not be available for the selection
    `void` | `setVideoTrackOverride​(VideoTrack videoTrack)` | Set video track override to be used during video selection

    - ### Methods inherited from class com.google.android.exoplayer2.trackselection.TrackSelector

      `init, selectTracks`

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### ExtendedTrackSelector

          public ExtendedTrackSelector()

    - #### ExtendedTrackSelector

          public ExtendedTrackSelector​(@NonNull
                                       com.castlabs.android.player.VideoTrackSelection.Factory videoTrackSelectionFactory,
                                       @Nullable
                                       ExtendedTrackSelector.PlayerInfoProvider playerInfoProvider,
                                       @Nullable
                                       ExtendedTrackSelector.EventListener eventListener,
                                       @Nullable
                                       PlayerConfig playerConfig)

  - ### Method Detail

    - #### setDisplaySize

          public void setDisplaySize​(@NonNull
                                     Point size)

    - #### setPreselectedVideoQualities

          public void setPreselectedVideoQualities​(@Nullable
                                                   int[] preselectedVideoQualityIndices)

      Preselect video qualities available for the selection
      Parameters:
        `preselectedVideoQualityIndices` - video qualities indices or `null` to reset previous values

    - #### setPreselectedAudio

          public void setPreselectedAudio​(@Nullable
                                          List<TrackIndexOverride> preselectedAudio)

      Preselect audio tracks available for the selection
      Parameters:
        `preselectedAudio` - audio indices or `null` to reset previous values

    - #### setPreselectedSubtitle

          public void setPreselectedSubtitle​(@Nullable
                                             List<TrackIndexOverride> preselectedSubtitle)

      Preselect subtitle tracks available for the selection
      Parameters:
        `preselectedSubtitle` - audio indices or `null` to reset previous values

    - #### setPreselectedSideloadedTracks

          public void setPreselectedSideloadedTracks​(@Nullable
                                                     List<SubtitleTrack> sideloadedTracks)

      Preselect sideloaded subtitle tracks available for the selection
      Parameters:
        `sideloadedTracks` - audio indices or `null` to reset previous values

    - #### setDisabledRendererIndices

          public void setDisabledRendererIndices​(@Nullable
                                                 List<Integer> disabledRendererIndices)

      Disable renderers by indices such that the tracks of the corresponding type will not be selected
      Parameters:
        `disabledRendererIndices` - renderers indices or `null` to reset previous values

    - #### setVideoHdEnabled

          public void setVideoHdEnabled​(boolean isHdPlaybackEnabled)

      Enable or disable the video HD tracks. Note that this has to be called before the initial track selection. The current selection will not be invalidated.
      Parameters:
        `isHdPlaybackEnabled` - `true` to enable otherwise `false`

    - #### setVideoMaxResolution

          public void setVideoMaxResolution​(int maxVideoWidth,
                                            int maxVideoHeight)

      Set the max video tracks resolution in pixels such that the video tracks with higher resolutions will not be available for the selection
      Parameters:
        `maxVideoWidth` - max video width in pixels
        `maxVideoHeight` - max video height in pixels

    - #### setVideoFilter

          public void setVideoFilter​(@NonNull
                                     VideoFilterConfiguration contentFilter,
                                     @Nullable
                                     VideoFilterConfiguration adsFilter)

      Sets the video filter for content and ads. In case the `adsFilter` is `null` then the content video filter is used for both content and ads tracks filtering
      Parameters:
        `contentFilter` - The video filter for content
        `adsFilter` - The video filter for ads or `null` to use content filter for ads

    - #### setVideoCodecFilter

          public void setVideoCodecFilter​(int videoCodecFilter)

      Set the video codec filtering policy, one of `SdkConsts.VideoCodecFilter`. Note that this has to be called before the initial track selection. The current selection will not be invalidated.
      Parameters:
        `videoCodecFilter` - video codec filter, one of `SdkConsts.VideoCodecFilter`

    - #### setVideoTrackOverride

          public void setVideoTrackOverride​(@Nullable
                                            VideoTrack videoTrack)

      Set video track override to be used during video selection
      Parameters:
        `videoTrack` - video track override

    - #### onLicenseKeysLoaded

          public void onLicenseKeysLoaded()

      Description copied from interface: `DrmEventListener`
      Called when a key was loaded successfully
      Specified by:
        `onLicenseKeysLoaded` in interface `DrmEventListener`

    - #### onLicenseKeysChanged

          public void onLicenseKeysChanged()

      Description copied from interface: `DrmEventListener`
      Called when keys are changed e.g. when license is renewed or expires
      Specified by:
        `onLicenseKeysChanged` in interface `DrmEventListener`

    - #### onLicenseLoadError

          public void onLicenseLoadError​(int currentAttempt,
                                         int maxAttempts,
                                         @Nullable
                                         DownloadException downloadException)

      Description copied from interface: `DrmEventListener`
      Called when license load error occurred
      Specified by:
        `onLicenseLoadError` in interface `DrmEventListener`
      Parameters:
        `currentAttempt` - The current loading attempt
        `maxAttempts` - The max number of attempts
        `downloadException` - The download exception

    - #### setInitialVideoTrackGroupIndex

          public void setInitialVideoTrackGroupIndex​(int initialVideoTrackGroupIndex)

      Set video track group index override to be used during video selection. Note that this has to be called before the initial track selection. The current selection will not be invalidated.
      Parameters:
        `initialVideoTrackGroupIndex` - video track group index override

    - #### setAudioTrackOverride

          public void setAudioTrackOverride​(@Nullable
                                            AudioTrack audioTrack)

      Set audio track override to be used during audio selection
      Parameters:
        `audioTrack` - audio track override

    - #### setAudioTrackIndexOverride

          public void setAudioTrackIndexOverride​(@Nullable
                                                 TrackIndexOverride trackIndexOverride)

      Set audio track indices override to be used during audio selection
      Parameters:
        `trackIndexOverride` - audio track indices override

    - #### setSubtitleTrackOverride

          public void setSubtitleTrackOverride​(@Nullable
                                               SubtitleTrack subtitleTrack)

      Set subtitle track override to be used during subtitle selection
      Parameters:
        `subtitleTrack` - subtitle track override

    - #### setSubtitleTrackIndexOverride

          public void setSubtitleTrackIndexOverride​(@Nullable
                                                    TrackIndexOverride trackIndexOverride)

      Set subtitle track indices override to be used during subtitle selection
      Parameters:
        `trackIndexOverride` - subtitle track indices override

    - #### getPreferredAudioLanguage

          @Nullable
          public String getPreferredAudioLanguage()

      Get the preferred audio language
      Returns:
        preferred audio language

    - #### getPreferredSubtitleLanguage

          @Nullable
          public String getPreferredSubtitleLanguage()

      Get the preferred subtitles language
      Returns:
        preferred subtitles language

    - #### selectTracks

          @NonNull
          public com.google.android.exoplayer2.trackselection.TrackSelectorResult selectTracks​(com.google.android.exoplayer2.RendererCapabilities[] rendererCapabilities,
                                                                                               com.google.android.exoplayer2.source.TrackGroupArray trackGroups,
                                                                                               com.google.android.exoplayer2.source.MediaSource.MediaPeriodId periodId,
                                                                                               com.google.android.exoplayer2.Timeline timeline,
                                                                                               Object manifest)
                                                                                        throws com.google.android.exoplayer2.ExoPlaybackException

      Specified by:
        `selectTracks` in class `com.google.android.exoplayer2.trackselection.TrackSelector`
      Throws:
        `com.google.android.exoplayer2.ExoPlaybackException`

    - #### onSelectionActivated

          public void onSelectionActivated​(Object info)

      Specified by:
        `onSelectionActivated` in class `com.google.android.exoplayer2.trackselection.TrackSelector`

    - #### createModel

          @Nullable
          public ExtendedTrackSelector.ModelSelection createModel​(@NonNull
                                                                  com.google.android.exoplayer2.trackselection.TrackSelectorResult trackSelectorResult)

    - #### extractDashThumbnails

          public static void extractDashThumbnails​(com.google.android.exoplayer2.source.dash.manifest.DashManifest dashManifest,
                                                   com.google.android.exoplayer2.Timeline timeline,
                                                   PlayerModel playerModel)

      Extracts the embedded thumbnail tracks in the DASH manifest, and updates the provided player model with them.
      Parameters:
        `dashManifest` - the DASH manifest which contains the thumbnail tracks to extract
        `timeline` - timeline representing provided manifest
        `playerModel` - player model to update with thumbnail tracks