Class PlayerConfig.Builder

java.lang.Object
com.castlabs.android.player.PlayerConfig.Builder
Enclosing class:
PlayerConfig

public static final class PlayerConfig.Builder extends Object
A Builder for PlayerConfig.
  • Constructor Details

    • Builder

      public Builder(@NonNull String url)
      Parameters:
      url - content url
    • Builder

      public Builder(@NonNull Bundle bundle)
      Parameters:
      bundle - a Bundle where to copy values from.
    • Builder

      public Builder(@NonNull PlayerConfig config)
      Parameters:
      config - an existing PlayerConfig where to copy values from.
  • Method Details

    • typeCheck

      public static Object typeCheck(@Nullable Object value, @NonNull Class<?> type, @Nullable Object defaultValue, @NonNull String errorMessage) throws IllegalArgumentException
      Helper function that we use to type check the value extracted from a bundle
      Parameters:
      value - the value
      type - the expected type
      defaultValue - the default value
      errorMessage - the error message
      Returns:
      the value in case the type check passed
      Throws:
      IllegalArgumentException - in case the type check fails
    • fromBundle

      @NonNull public PlayerConfig.Builder fromBundle(@NonNull Bundle bundle)
      Sets the Builder fields according to the stored keys in the given Bundle.
      Parameters:
      bundle - the Bundle where to get the values from
      Returns:
      the Builder
    • fromConfig

      @NonNull public PlayerConfig.Builder fromConfig(@NonNull PlayerConfig config)
      Sets the Builder fields according to the values from the given PlayerConfig
      Parameters:
      config - the PlayerConfig from which to read the values.
      Returns:
      the Builder
    • positionUs

      @NonNull public PlayerConfig.Builder positionUs(long positionUs)
      Sets the position in microseconds
      Parameters:
      positionUs - the value
      Returns:
      the Builder
    • clippingStartUs

      @NonNull public PlayerConfig.Builder clippingStartUs(long clippingStartUs)
      Sets the clipping start position in microseconds
      Parameters:
      clippingStartUs - the value
      Returns:
      the Builder
    • clippingEndUs

      @NonNull public PlayerConfig.Builder clippingEndUs(long clippingEndUs)
      Sets the clipping start position in microseconds
      Parameters:
      clippingEndUs - the value
      Returns:
      the Builder
    • subtitlesTrackGroupIndex

      @NonNull public PlayerConfig.Builder subtitlesTrackGroupIndex(int subtitlesTrackGroupIndex)
      Sets the subtitles track group index
      Parameters:
      subtitlesTrackGroupIndex - the value
      Returns:
      the Builder
    • subtitlesTrackIndex

      @NonNull public PlayerConfig.Builder subtitlesTrackIndex(int subtitlesTrackIndex)
      Sets the subtitles track index
      Parameters:
      subtitlesTrackIndex - the value
      Returns:
      the Builder
    • audioTrackGroupIndex

      @NonNull public PlayerConfig.Builder audioTrackGroupIndex(int audioTrackGroupIndex)
      Sets the audio track group index
      Parameters:
      audioTrackGroupIndex - the value
      Returns:
      the Builder
    • audioTrackIndex

      @NonNull public PlayerConfig.Builder audioTrackIndex(int audioTrackIndex)
      Sets the audio track index
      Parameters:
      audioTrackIndex - the value
      Returns:
      the Builder
    • volume

      @NonNull public PlayerConfig.Builder volume(float volume)
      Sets the volume. 1 is the maximum, and 0 the minimum.
      Parameters:
      volume - the value
      Returns:
      the Builder
    • pauseOnHdmiDisconnected

      @NonNull public PlayerConfig.Builder pauseOnHdmiDisconnected(boolean pauseOnHdmiDisconnected)
      Enable or disable automatic playback pause on HDMI disconnect Only for API higher or equal to 21
      Parameters:
      pauseOnHdmiDisconnected - the value
      Returns:
      the Builder
    • videoTrackGroupIndex

      @NonNull public PlayerConfig.Builder videoTrackGroupIndex(int videoTrackGroupIndex)
      Sets the video track group index
      Parameters:
      videoTrackGroupIndex - the value
      Returns:
      the Builder
    • abrConfiguration

      @NonNull public PlayerConfig.Builder abrConfiguration(AbrConfiguration abrConfiguration)
      Parameters:
      abrConfiguration - the value
      Returns:
      the Builder
    • bufferConfiguration

      @NonNull public PlayerConfig.Builder bufferConfiguration(BufferConfiguration bufferConfiguration)
      Parameters:
      bufferConfiguration - the value
      Returns:
      the Builder
    • mergeVideoTracks

      @NonNull public PlayerConfig.Builder mergeVideoTracks(boolean mergeVideoTracks)
      Sets whether to merge video tracks
      Parameters:
      mergeVideoTracks - the value
      Returns:
      the Builder
    • clipPeriods

      @NonNull public PlayerConfig.Builder clipPeriods(boolean clipPeriods)
      Sets whether to clip periods to their durations (DASH-only) May be necessary when the segments durations are longer than the periods or the segments durations are not-aligned, so the periods should be clipped to periods durations and don't render the segments leftovers. Default is PlayerSDK.CLIP_PERIODS
      Parameters:
      clipPeriods - the value
      Returns:
      the Builder
    • forceInStreamDrmInitData

      @NonNull public PlayerConfig.Builder forceInStreamDrmInitData(boolean forceInStreamDrmInitData)
      Sets whether to use DRM init data coming from segments or from the manifest (DASH-only). The flag does not affect key pre-fetch and initialization data. Set it to true when a key is changed in a segment and not in the manifest Default is PlayerSDK.FORCE_IN_STREAM_DRM_INIT_DATA
      Parameters:
      forceInStreamDrmInitData - the value
      Returns:
      the Builder
    • enableWorkaroundEveryVideoFrameIsSyncFrame

      @NonNull public PlayerConfig.Builder enableWorkaroundEveryVideoFrameIsSyncFrame(boolean enableWorkaroundEveryVideoFrameIsSyncFrame)
      Sets whether to enable or disable the workaround whether all video frames are marked as sync frames but should not be treated as sync frames except the very first in a segment (DASH-only). Default is PlayerSDK.ENABLE_WORKAROUND_EVERY_VIDEO_FRAME_IS_SYNC_FRAME
      Parameters:
      enableWorkaroundEveryVideoFrameIsSyncFrame - the value
      Returns:
      the Builder
    • videoCodecFilter

      @NonNull public PlayerConfig.Builder videoCodecFilter(int videoCodecFilter)
      Sets the type of video codec filter
      Parameters:
      videoCodecFilter - the value
      Returns:
      the Builder
    • mediaCodecInfos

      @NonNull public PlayerConfig.Builder mediaCodecInfos(ArrayList<MediaCodecInfo> mediaCodecInfos)
      Sets the preferred codecs for specified mimetypes. In case the specified codec does not present on the system then the setting is ignored
      Parameters:
      mediaCodecInfos - the value
      Returns:
      the Builder
    • videoCodec

      @NonNull public PlayerConfig.Builder videoCodec(@Nullable String codecName)
      Sets the preferred video codec for all video types. To set preferred video codec for specific mimetype, use mediaCodecInfos(ArrayList). In case the specified codec does not present on the system then the setting is ignored
      Parameters:
      codecName - the codec name as registered in the system e.g. "OMX.google.h264.decoder"
      Returns:
      the Builder
    • audioCodec

      @NonNull public PlayerConfig.Builder audioCodec(@Nullable String codecName)
      Sets the preferred audio codec for all audio types. To set preferred audio codec for specific mimetype, use mediaCodecInfos(ArrayList). In case the specified codec does not present on the system then the setting is ignored
      Parameters:
      codecName - the codec name as registred in the system e.g. "OMX.google.h264.decoder"
      Returns:
      the Builder
    • videoSizeFilter

      @NonNull public PlayerConfig.Builder videoSizeFilter(Point videoSizeFilter)
      Sets the video size filter
      Parameters:
      videoSizeFilter - the value
      Returns:
      the Builder
    • downloadFolder

      @NonNull public PlayerConfig.Builder downloadFolder(String downloadFolder)
      Sets the download folder
      Parameters:
      downloadFolder - the value
      Returns:
      the Builder
    • enableTunneling

      @NonNull public PlayerConfig.Builder enableTunneling(boolean enableTunneling)
      Sets whether to enable tunneling
      Parameters:
      enableTunneling - the value
      Returns:
      the Builder
    • enableTunnelingWithoutAudio

      @NonNull public PlayerConfig.Builder enableTunnelingWithoutAudio(boolean enableTunnelingWithoutAudio)
      Sets whether to force tunneling with only video track present. To take effect the enableTunneling(boolean) should also be on.
      Parameters:
      enableTunnelingWithoutAudio - the value
      Returns:
      the Builder
    • analyticsSessionType

      @NonNull public PlayerConfig.Builder analyticsSessionType(int analyticsSessionType)
      Sets the type of analytics session
      Parameters:
      analyticsSessionType - the value
      Returns:
      the Builder
    • userID

      @NonNull public PlayerConfig.Builder userID(String userID)
      Sets the user ID
      Parameters:
      userID - the value
      Returns:
      the Builder
    • liveConfiguration

      @NonNull public PlayerConfig.Builder liveConfiguration(LiveConfiguration liveConfiguration)
      Parameters:
      liveConfiguration - the value
      Returns:
      the Builder
    • networkConfiguration

      @NonNull public PlayerConfig.Builder networkConfiguration(@NonNull NetworkConfiguration networkConfiguration)
      Parameters:
      networkConfiguration - the value
      Returns:
      the Builder
    • trickplayConfiguration

      @NonNull public PlayerConfig.Builder trickplayConfiguration(TrickplayConfiguration trickplayConfiguration)
      Parameters:
      trickplayConfiguration - the value
      Returns:
      the Builder
    • enableTrickplayMode

      @NonNull public PlayerConfig.Builder enableTrickplayMode(boolean enableTrickplayMode)
      Whether to enable Trickplay playback on start or not
      Parameters:
      enableTrickplayMode - whether to enable Trickplay playback on start or not
      Returns:
      the Builder
    • enableDashEventCallback

      @NonNull public PlayerConfig.Builder enableDashEventCallback(boolean enableDashEventCallback)
      Whether to enable internal handling of DASH event callbacks
      Parameters:
      enableDashEventCallback - whether to enable internal handling of DASH event callback
      Returns:
      the Builder
    • adRequest

      @NonNull public PlayerConfig.Builder adRequest(AdRequest adRequest)
      Sets the AdRequest
      Parameters:
      adRequest - the value
      Returns:
      the Builder
    • enableAdSpeedUp

      @NonNull public PlayerConfig.Builder enableAdSpeedUp(boolean enableAdSpeedUp)
      Sets the flag to enable or disable automatic setting of a speed to 1x when playing ads.
      Parameters:
      enableAdSpeedUp - The flag
      Returns:
      the Builder
    • restoreSpeed

      @NonNull public PlayerConfig.Builder restoreSpeed(boolean restoreSpeed)
      Sets the flag to enable or disable automatic restoring of a speed after playing ads.
      Parameters:
      restoreSpeed - The flag
      Returns:
      the Builder
    • configurationUrl

      @NonNull public PlayerConfig.Builder configurationUrl(String configurationUrl)
      Sets the configuration url
      Parameters:
      configurationUrl - the value
      Returns:
      the Builder
    • id

      @NonNull public PlayerConfig.Builder id(String id)
      Sets the configuration id
      Parameters:
      id - the value
      Returns:
      the Builder
    • contentUrl

      @NonNull public PlayerConfig.Builder contentUrl(@NonNull String contentUrl)
      Sets the content url. This is the only mandatory param
      Parameters:
      contentUrl - the value. Cannot be null or empty.
      Returns:
      the Builder
    • contentType

      @NonNull public PlayerConfig.Builder contentType(int contentType)
      Sets the content type
      Parameters:
      contentType - the value
      Returns:
      the Builder
    • autoPlay

      @NonNull public PlayerConfig.Builder autoPlay(boolean autoPlay)
      Sets whether to start playing once enough buffer is available
      Parameters:
      autoPlay - the value
      Returns:
      the Builder
    • live

      @NonNull public PlayerConfig.Builder live(boolean live)
      Sets whether this is live content
      Parameters:
      live - the value
      Returns:
      the Builder
    • threesixty

      @NonNull public PlayerConfig.Builder threesixty(boolean threesixty)
      Sets whether this is 360 content
      Parameters:
      threesixty - the value
      Returns:
      the Builder
    • preferredTextLanguage

      @NonNull public PlayerConfig.Builder preferredTextLanguage(String preferredTextLanguage)
      Sets the preferred text language
      Parameters:
      preferredTextLanguage - the value
      Returns:
      the Builder
    • preferredAudioLanguage

      @NonNull public PlayerConfig.Builder preferredAudioLanguage(String preferredAudioLanguage)
      Sets the preferred audio language
      Parameters:
      preferredAudioLanguage - the value
      Returns:
      the Builder
    • sideloadedTracks

      @NonNull public PlayerConfig.Builder sideloadedTracks(ArrayList<SideloadedTrack> sideloadedTracks)
      Sets the sideloaded tracks
      Parameters:
      sideloadedTracks - the value
      Returns:
      the Builder
    • metaData

      @NonNull public PlayerConfig.Builder metaData(Bundle metaData)
      Sets the Bundle metadata
      Parameters:
      metaData - the value
      Returns:
      the Builder
    • contentParameters

      @NonNull public PlayerConfig.Builder contentParameters(Bundle contentParameters)
      Sets the manifest header parameters
      Parameters:
      contentParameters - the value
      Returns:
      the Builder
    • segmentParameters

      @NonNull public PlayerConfig.Builder segmentParameters(Bundle segmentParameters)
      Sets the segment header parameters
      Parameters:
      segmentParameters - the value
      Returns:
      the Builder
    • segmentQueryParameters

      @NonNull public PlayerConfig.Builder segmentQueryParameters(Bundle segmentQueryParameters)
      Sets the segment query parameters
      Parameters:
      segmentQueryParameters - the value
      Returns:
      the Builder
    • contentQueryParameters

      @NonNull public PlayerConfig.Builder contentQueryParameters(Bundle contentQueryParameters)
      Sets the segment query parameters
      Parameters:
      contentQueryParameters - the value
      Returns:
      the Builder
    • drmConfiguration

      @NonNull public PlayerConfig.Builder drmConfiguration(DrmConfiguration drmConfiguration)
      Parameters:
      drmConfiguration - the value
      Returns:
      the Builder
    • casConfiguration

      @NonNull public PlayerConfig.Builder casConfiguration(CasConfiguration casConfiguration)
      Parameters:
      casConfiguration - the value
      Returns:
      the Builder
    • preservePlayerViewSurface

      @NonNull public PlayerConfig.Builder preservePlayerViewSurface(boolean preservePlayerViewSurface)
      If set to true and the PlayerView is used, the playback surface be kept on screen and preserved when the player player is released. This allows to reuse (instead of re-create) the playback surface and can also be used to keep the last frame on screen even if the underlying player was already released.
      Parameters:
      preservePlayerViewSurface - The value
      Returns:
      The Builder
    • preservePlayerResources

      @NonNull public PlayerConfig.Builder preservePlayerResources(boolean preservePlayerResources)
      If set to true, the playback resources like codecs and renderers will be preserved when the player is released. This allows to reuse (instead of re-create) the playback resources and can also be used to keep the last frame on screen when preservePlayerViewSurface is set.
      Parameters:
      preservePlayerResources - The value
      Returns:
      The Builder
    • pushBlackScreenOnDispose

      @NonNull public PlayerConfig.Builder pushBlackScreenOnDispose(boolean pushBlackScreenOnDispose)
      If set to true and preservePlayerViewSurface is enabled, indicates that the decoder should push a black screen to the surface when disposed.
      Parameters:
      pushBlackScreenOnDispose - The value
      Returns:
      The Builder
    • useStandaloneMediaClock

      @NonNull public PlayerConfig.Builder useStandaloneMediaClock(boolean useStandaloneMediaClock)
      If set to true, will use Exoplayer's StandaloneMediaClock instead of the Renderer Clock.

      There's a known issue when using SingleControllerPlaylist in conjunction with Audio Tracks which don't span the entire media duration. With the default Renderer Clock this provokes a freeze when the Audio Track ends.

      Parameters:
      useStandaloneMediaClock - The value
      Returns:
      The Builder
    • enableLooping

      @NonNull public PlayerConfig.Builder enableLooping(boolean enableLooping)
      If set to true then the playback looping will be enabled and the player will automatically restart the playback after reaching end of content
      Parameters:
      enableLooping - The value
      Returns:
      The Builder
    • analyticsMetaData

      @NonNull public PlayerConfig.Builder analyticsMetaData(AnalyticsMetaData analyticsMetaData)
      Set the analytics meta-data
      Parameters:
      analyticsMetaData - The analytics meta-data
      Returns:
      The builder
    • audioAttributes

      @NonNull public PlayerConfig.Builder audioAttributes(AudioAttributes audioAttributes)
      Set the AudioAttributes
      Parameters:
      audioAttributes - The audio attributes
      Returns:
      The builder
    • adSchedule

      @NonNull public PlayerConfig.Builder adSchedule(AdSchedule adSchedule)
      Set the AdSchedule
      Parameters:
      adSchedule - The ad schedule
      Returns:
      The builder
    • videoFilterConfiguration

      @NonNull public PlayerConfig.Builder videoFilterConfiguration(VideoFilterConfiguration videoFilterConfiguration)
      Set the VideoFilterConfiguration
      Parameters:
      videoFilterConfiguration - The VideoFilterConfiguration
      Returns:
      The builder
    • useEth0

      @NonNull public PlayerConfig.Builder useEth0(boolean useEth0)
      If set to true then the SDK if IPTV is used, eth0 will be used for multicast for multicast reception
      Parameters:
      useEth0 - The value
      Returns:
      The Builder
    • videoDecoderFallback

      @NonNull public PlayerConfig.Builder videoDecoderFallback(boolean value)
      If true (default), allows the player to fallback to other decoders if it failed to initialize the primary decoder. This can for instance happen if the primary decoder is a hardware implementation and is already blocked by another playback session. In that case, secondary decoders, i.e. software implementations, will be used if possible.
      Parameters:
      value - The value
      Returns:
      The builder
    • audioDecoderFallback

      @NonNull public PlayerConfig.Builder audioDecoderFallback(boolean value)
      If true (default), allows the player to fallback to other decoders if it failed to initialize the primary decoder. This can for instance happen if the primary decoder is a hardware implementation and is already blocked by another playback session. In that case, secondary decoders, i.e. software implementations, will be used if possible.
      Parameters:
      value - The value
      Returns:
      The builder
    • unsecureDecoderFallback

      @NonNull public PlayerConfig.Builder unsecureDecoderFallback(boolean value)
      If true (default), allows the player to fallback to unsecure decoders if it failed to initialize the primary decoder. This requires videoDecoderFallback(boolean) )} to be enabled.
      Parameters:
      value - The value
      Returns:
      The builder
    • allowHlsChunklessPreparation

      @NonNull public PlayerConfig.Builder allowHlsChunklessPreparation(boolean value)
      If set to true, chunk-less preparation of hls tracks are allowed
      Parameters:
      value - The value
      Returns:
      The builder
    • subtitleSubSampleType

      @NonNull public PlayerConfig.Builder subtitleSubSampleType(int value)
      Defines whether the subtitle times are absolute or relative. Could be one of SdkConsts.SUBTITLE_SUB_SAMPLE_TYPE_ABSOLUTE or SdkConsts.SUBTITLE_SUB_SAMPLE_TYPE_RELATIVE.
      Parameters:
      value - The value
      Returns:
      The builder
    • get

      @NonNull public PlayerConfig get()
      Builds the PlayerConfig object
      Returns:
      the PlayerConfig object