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

      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

      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

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

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

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

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

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

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

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

      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

      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

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

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

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

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

      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

      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

      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

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

      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

      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

      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

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

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

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

      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

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

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

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

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

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

      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

      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

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

      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

      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

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

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

      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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      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
    • pushBlackScreenOnDispose

      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

      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

      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

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

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

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

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

      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

      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

      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

      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

      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

      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

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