Package com.castlabs.android.player

# Class PlayerConfig

java.lang.Object
com.castlabs.android.player.PlayerConfig

All Implemented Interfaces:
  `Parcelable`

public class PlayerConfig extends Object implements Parcelable
Object which represents a specific Player configuration.

You can use a `PlayerConfig` object to start playback on a `PlayerController` calling its `PlayerController.open(PlayerConfig)` method.

An instance can be built with the `PlayerConfig.Builder`. The `Builder` can be populated with an already existing `PlayerConfig` or with a `Bundle`.

It is possible to convert an instance of `PlayerConfig` `toBundle()`. This `Bundle` can also be used to `PlayerController.open(Bundle)` the `PlayerController`.

This class is `Parcelable`.

Since:
  4.2.1

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static final class`
  `PlayerConfig.Builder`
  A Builder for `PlayerConfig`.

  ## Nested classes/interfaces inherited from interface android.os.Parcelable

  `Parcelable.ClassLoaderCreator<T>, Parcelable.Creator<T>`

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `final AbrConfiguration`
  `abrConfiguration`
  The initial video quality
  `final AdRequest`
  `adRequest`
  The Ad request (if any)
  `AdSchedule`
  `adSchedule`
  Describes a custom ad schedule.
  `final boolean`
  `allowHlsChunklessPreparation`
  If set to true, chunk-less preparation of hls tracks are allowed
  `AnalyticsMetaData`
  `analyticsMetaData`
  The analytics meta-data
  `final int`
  `analyticsSessionType`
  Analytics session type
  `AudioAttributes`
  `audioAttributes`
  The Audio Attributes.
  `final boolean`
  `audioDecoderFallback`
  If true (default), allows the player to fallback to other decoders if it failed to initialize the primary decoder.
  `final int`
  `audioTrackGroupIndex`
  The index of the selected audio track group
  `final int`
  `audioTrackIndex`
  The index of the selected audio track
  `final boolean`
  `autoPlay`
  Whether to autoplay or not
  `final BufferConfiguration`
  `bufferConfiguration`
  The buffer configuration
  `final CasConfiguration`
  `casConfiguration`
  Cas configuration (if any)
  `final boolean`
  `clipPeriods`
  If true then media periods will be clipped to their durations (currently is only applicable for DASH streams)
  `final long`
  `clippingEndUs`
  The clipping end position in microseconds
  `final long`
  `clippingStartUs`
  The clipping start position in microseconds
  `final String`
  `configurationUrl`
  Optional configuration backend url
  `final Bundle`
  `contentParameters`
  Header params to add to content (manifest) requests
  `final Bundle`
  `contentQueryParameters`
  Query params to add to content (manifest) requests
  `final int`
  `contentType`
  The content format
  `final String`
  `contentUrl`
  Playback url
  `static final Parcelable.Creator<PlayerConfig>`
  `CREATOR`
  Creator for the `PlayerConfig` class.
  `final String`
  `downloadFolder`
  Download folder in case the content is played offline
  `final DrmConfiguration`
  `drmConfiguration`
  Drm configuration (if any)
  `final boolean`
  `enableAdSpeedUp`
  The flag to enable or disable automatic setting of a speed to 1x when playing ads.
  `final boolean`
  `enableDashEventCallback`
  Enable internal handling of DASH event callbacks
  `final 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
  `final boolean`
  `enableTrickplayMode`
  Enable Trickplay mode at the start of the playback.
  `final boolean`
  `enableTunneling`
  Enable tunneling support
  `final boolean`
  `enableTunnelingWithoutAudio`
  Force using of tunneling when audio track is disabled.
  `final boolean`
  `enableWorkaroundEveryVideoFrameIsSyncFrame`
  If True, the workaround will be enabled to not treat the video frames as sync frames except the very first one.
  `final boolean`
  `forceInStreamDrmInitData`
  If true then DRM init data from segments will be used instead of the one from manifest (currently is only applicable for DASH streams)
  `final String`
  `id`
  ID for this content
  `static final String`
  `INTENT_CONFIGURATION_ID`
  A unique ID for the configuration
  `static final String`
  `INTENT_CONFIGURATION_URL`
  Intent key to specify an optional URL to an API endpoint that can be used to refresh the configuration.
  `static final String`
  `INTENT_LIVE`
  Indicates live content
  `static final String`
  `INTENT_METADATA`
  Additional Bundle-formatted meta-data such as poster images, titles, byline and any custom meta-data
  `static final String`
  `INTENT_PREFERRED_CODEC_INFOS`
  Preferred media codec infos
  `static final String`
  `INTENT_THREESIXTY`
  Indicates 360 degree content
  `final boolean`
  `live`
  Content live or VoD
  `final LiveConfiguration`
  `liveConfiguration`
  The Live configuration
  `final boolean`
  `mergeVideoTracks`
  If True, the video tracks will be merged into a single video track
  `final Bundle`
  `metaData`
  Optional metadata
  `final NetworkConfiguration`
  `networkConfiguration`
  The network configuration
  `final boolean`
  `pauseOnHdmiDisconnected`
  Enable or disable automatic pausing on HDMI disconnected
  `final long`
  `positionUs`
  The position in microseconds.
  `final String`
  `preferredAudioLanguage`
  Preferred audio language
  `final List<MediaCodecInfo>`
  `preferredCodecInfos`
  List of preferred MediaCodecInfos.
  `final String`
  `preferredTextLanguage`
  Preferred subtitles language
  `final boolean`
  `preservePlayerResources`
  If set to true, the playback resources (codecs, renderers) will be preserved when the player player is released.
  `final 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.
  `final boolean`
  `pushBlackScreenOnDispose`
  If true, indicates if the decoder should push a black screen to the surface when disposed.
  `final boolean`
  `restoreSpeed`
  The flag to enable or disable automatic restoring of a speed after playing ads.
  `final Bundle`
  `segmentParameters`
  Header params to add to segment requests
  `final Bundle`
  `segmentQueryParameters`
  Query params to add to segment requests
  `final List<SideloadedTrack>`
  `sideloadedTracks`
  Array of side-loaded tracks, either subtitles or thumbnails
  `final int`
  `subtitlesTrackGroupIndex`
  The index of the selected subtitle track group or -1 for if subtitles are disabled
  `final int`
  `subtitlesTrackIndex`
  The index of the selected subtitle track or -1 for if subtitles are disabled
  `final int`
  `subtitleSubSampleType`
  Defines whether the subtitle times are absolute or relative.
  `final boolean`
  `threesixty`
  360 support
  `final TrickplayConfiguration`
  `trickplayConfiguration`
  The Trickplay configuration
  `final boolean`
  `unsecureDecoderFallback`
  If true (default), allows the player to fallback to unsecure decoders if it failed to initialize the primary decoder.
  `final boolean`
  `useEth0`
  A boolean flag to indicate to use eth0 for multicast reception
  `final String`
  `userID`
  User ID.
  `boolean`
  `useStandaloneMediaClock`
  If set to true, will use Exoplayer's `StandaloneMediaClock` instead of the Renderer Clock.
  `final int`
  `videoCodecFilter`
  The video codec filter
  `final boolean`
  `videoDecoderFallback`
  If true (default), allows the player to fallback to other decoders if it failed to initialize the primary decoder.
  `final VideoFilterConfiguration`
  `videoFilterConfiguration`
  The video filter configuration
  `final Point`
  `videoSizeFilter`
  Deprecated.
  Use `VideoFilterConfiguration.maxPixel` instead.
  `final int`
  `videoTrackGroupIndex`
  The index of the selected video track group
  `final float`
  `volume`
  The audio track volume

  ### Fields inherited from interface android.os.Parcelable

  `CONTENTS_FILE_DESCRIPTOR, PARCELABLE_WRITE_RETURN_VALUE`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `PlayerConfig.Builder`
  `buildUpon()`
  Set the `Builder` values to the stored values in the `Bundle`.
  `int`
  `describeContents()`
  `boolean`
  `equals(Object obj)`
  `static int`
  `guessFormat(String url)`
  Guess the format of the or return `SdkConsts.CONTENT_TYPE_UNKNOWN`.
  `int`
  `hashCode()`
  `void`
  `save(Bundle bundle)`
  Saves the current configuration into a `Bundle`.
  `Bundle`
  `toBundle()`
  Obtain a `Bundle` filled with key-value pairs representing the current configuration.
  `void`
  `writeToParcel(Parcel dest, int flags)`

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

  `getClass, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### INTENT_CONFIGURATION_URL

    public static final String INTENT_CONFIGURATION_URL
    Intent key to specify an optional URL to an API endpoint that can be used to refresh the configuration.

    This is intended only informative purposes, no actual refreshing will be performed by the SDK.

    See Also:
      - Constant Field Values

  - ### INTENT_CONFIGURATION_ID

    public static final String INTENT_CONFIGURATION_ID
    A unique ID for the configuration
    See Also:
      - Constant Field Values

  - ### INTENT_LIVE

    public static final String INTENT_LIVE
    Indicates live content
    See Also:
      - Constant Field Values

  - ### INTENT_THREESIXTY

    public static final String INTENT_THREESIXTY
    Indicates 360 degree content
    See Also:
      - Constant Field Values

  - ### INTENT_METADATA

    public static final String INTENT_METADATA
    Additional Bundle-formatted meta-data such as poster images, titles, byline and any custom meta-data
    See Also:
      - Constant Field Values

  - ### INTENT_PREFERRED_CODEC_INFOS

    public static final String INTENT_PREFERRED_CODEC_INFOS
    Preferred media codec infos
    See Also:
      - Constant Field Values

  - ### positionUs

    public final long positionUs
    The position in microseconds. If set, `LiveConfiguration.liveEdgeLatencyMs` will be ignored. If there's an `InitialPositionProvider`, it will take precedence over this setting.

  - ### clippingStartUs

    public final long clippingStartUs
    The clipping start position in microseconds

  - ### clippingEndUs

    public final long clippingEndUs
    The clipping end position in microseconds

  - ### subtitlesTrackGroupIndex

    public final int subtitlesTrackGroupIndex
    The index of the selected subtitle track group or -1 for if subtitles are disabled

  - ### subtitlesTrackIndex

    public final int subtitlesTrackIndex
    The index of the selected subtitle track or -1 for if subtitles are disabled

  - ### audioTrackGroupIndex

    public final int audioTrackGroupIndex
    The index of the selected audio track group

  - ### audioTrackIndex

    public final int audioTrackIndex
    The index of the selected audio track

  - ### volume

    public final float volume
    The audio track volume

  - ### pauseOnHdmiDisconnected

    public final boolean pauseOnHdmiDisconnected
    Enable or disable automatic pausing on HDMI disconnected

  - ### videoTrackGroupIndex

    public final int videoTrackGroupIndex
    The index of the selected video track group

  - ### abrConfiguration

    @Nullable public final AbrConfiguration abrConfiguration
    The initial video quality

  - ### bufferConfiguration

    @Nullable public final BufferConfiguration bufferConfiguration
    The buffer configuration

  - ### liveConfiguration

    @Nullable public final LiveConfiguration liveConfiguration
    The Live configuration

  - ### networkConfiguration

    @NonNull public final NetworkConfiguration networkConfiguration
    The network configuration

  - ### trickplayConfiguration

    @NonNull public final TrickplayConfiguration trickplayConfiguration
    The Trickplay configuration

  - ### enableTrickplayMode

    public final boolean enableTrickplayMode
    Enable Trickplay mode at the start of the playback.
    See Also:
      - `trickplayConfiguration`

  - ### enableDashEventCallback

    public final boolean enableDashEventCallback
    Enable internal handling of DASH event callbacks

  - ### mergeVideoTracks

    public final boolean mergeVideoTracks
    If True, the video tracks will be merged into a single video track

  - ### enableWorkaroundEveryVideoFrameIsSyncFrame

    public final boolean enableWorkaroundEveryVideoFrameIsSyncFrame
    If True, the workaround will be enabled to not treat the video frames as sync frames except the very first one. This flag may be needed to set up when the metadata of a video frame reports the video frame to be a sync frame (which is not in fact) but should not be treated as a sync frame by the decoder i.e. without the workaround the video artifacts appear upon every playback start and seek until the real key frame is rendered.

  - ### clipPeriods

    public final boolean clipPeriods
    If true then media periods will be clipped to their durations (currently is only applicable for DASH streams)

  - ### forceInStreamDrmInitData

    public final boolean forceInStreamDrmInitData
    If true then DRM init data from segments will be used instead of the one from manifest (currently is only applicable for DASH streams)

  - ### videoCodecFilter

    public final int videoCodecFilter
    The video codec filter

  - ### videoSizeFilter

    public final Point videoSizeFilter
    Deprecated.
    Use `VideoFilterConfiguration.maxPixel` instead.
    The video size filter

  - ### preferredCodecInfos

    @NonNull public final List<MediaCodecInfo> preferredCodecInfos
    List of preferred MediaCodecInfos.

  - ### downloadFolder

    @Nullable public final String downloadFolder
    Download folder in case the content is played offline

  - ### enableTunneling

    public final boolean enableTunneling
    Enable tunneling support

  - ### enableTunnelingWithoutAudio

    public final boolean enableTunnelingWithoutAudio
    Force using of tunneling when audio track is disabled. To take effect the `enableTunneling` should also be on.

  - ### analyticsSessionType

    public final int analyticsSessionType
    Analytics session type

  - ### userID

    @Nullable public final String userID
    User ID. Unique identifier for the current user.

  - ### adRequest

    @Nullable public final AdRequest adRequest
    The Ad request (if any)

  - ### enableAdSpeedUp

    public final boolean enableAdSpeedUp
    The flag to enable or disable automatic setting of a speed to 1x when playing ads.

  - ### restoreSpeed

    public final boolean restoreSpeed
    The flag to enable or disable automatic restoring of a speed after playing ads.

  - ### configurationUrl

    @Nullable public final String configurationUrl
    Optional configuration backend url

  - ### id

    @NonNull public final String id
    ID for this content

  - ### contentUrl

    @NonNull public final String contentUrl
    Playback url

  - ### contentType

    public final int contentType
    The content format

  - ### autoPlay

    public final boolean autoPlay
    Whether to autoplay or not

  - ### live

    public final boolean live
    Content live or VoD

  - ### threesixty

    public final boolean threesixty
    360 support

  - ### preferredTextLanguage

    @Nullable public final String preferredTextLanguage
    Preferred subtitles language

  - ### preferredAudioLanguage

    @Nullable public final String preferredAudioLanguage
    Preferred audio language

  - ### sideloadedTracks

    @NonNull public final List<SideloadedTrack> sideloadedTracks
    Array of side-loaded tracks, either subtitles or thumbnails

  - ### metaData

    @Nullable public final Bundle metaData
    Optional metadata

  - ### contentParameters

    @Nullable public final Bundle contentParameters
    Header params to add to content (manifest) requests

  - ### segmentParameters

    @Nullable public final Bundle segmentParameters
    Header params to add to segment requests

  - ### contentQueryParameters

    public final Bundle contentQueryParameters
    Query params to add to content (manifest) requests

  - ### segmentQueryParameters

    @Nullable public final Bundle segmentQueryParameters
    Query params to add to segment requests

  - ### drmConfiguration

    @Nullable public final DrmConfiguration drmConfiguration
    Drm configuration (if any)

  - ### casConfiguration

    @Nullable public final CasConfiguration casConfiguration
    Cas configuration (if any)

  - ### preservePlayerViewSurface

    public final 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.

  - ### preservePlayerResources

    public final boolean preservePlayerResources
    If set to true, the playback resources (codecs, renderers) will be preserved when the player 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.

  - ### pushBlackScreenOnDispose

    public final boolean pushBlackScreenOnDispose
    If true, indicates if the decoder should push a black screen to the surface when disposed. This is only relevant if you enabled `preservePlayerViewSurface`

  - ### useStandaloneMediaClock

    public boolean useStandaloneMediaClock
    If set to true, will use Exoplayer's `StandaloneMediaClock` instead of the Renderer Clock.

  - ### enableLooping

    public final 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

  - ### analyticsMetaData

    @Nullable public AnalyticsMetaData analyticsMetaData
    The analytics meta-data

  - ### audioAttributes

    @Nullable public AudioAttributes audioAttributes
    The Audio Attributes. If set to `SdkConsts.AUDIO_ATTRIBUTES_FOCUS_DISABLED`, the SDK won't request Audio Focus and play sound regardless of it. It is recommended to provide an instance of `AudioAttributes`, or at least use the default configuration.

  - ### adSchedule

    @Nullable public AdSchedule adSchedule
    Describes a custom ad schedule.

  - ### videoFilterConfiguration

    @NonNull public final VideoFilterConfiguration videoFilterConfiguration
    The video filter configuration

  - ### useEth0

    @Nullable public final boolean useEth0
    A boolean flag to indicate to use eth0 for multicast reception

  - ### videoDecoderFallback

    public final boolean videoDecoderFallback
    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.

  - ### audioDecoderFallback

    public final boolean audioDecoderFallback
    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.

  - ### unsecureDecoderFallback

    public final boolean unsecureDecoderFallback
    If true (default), allows the player to fallback to unsecure decoders if it failed to initialize the primary decoder. This requires `videoDecoderFallback` to also be enabled.

  - ### allowHlsChunklessPreparation

    public final boolean allowHlsChunklessPreparation
    If set to true, chunk-less preparation of hls tracks are allowed

  - ### subtitleSubSampleType

    public final int subtitleSubSampleType
    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`

  - ### CREATOR

    public static final Parcelable.Creator<PlayerConfig> CREATOR
    Creator for the `PlayerConfig` class.

- ## Method Details

  - ### guessFormat

    public static int guessFormat(@NonNull String url)
    Guess the format of the or return `SdkConsts.CONTENT_TYPE_UNKNOWN`.
    Parameters:
      `url` - the url to the content
    Returns:
      the format or `SdkConsts.CONTENT_TYPE_UNKNOWN`

  - ### save

    public void save(@NonNull Bundle bundle)
    Saves the current configuration into a `Bundle`.
    Parameters:
      `bundle` - the Bundle to which store the `PlayerConfig`

  - ### toBundle

    public Bundle toBundle()
    Obtain a `Bundle` filled with key-value pairs representing the current configuration. This Bundle can be used to `start playback` on a `PlayerController`.
    Returns:
      the Bundle

  - ### buildUpon

    public PlayerConfig.Builder buildUpon()
    Set the `Builder` values to the stored values in the `Bundle`.
    Returns:
      the Builder

  - ### describeContents

    public int describeContents()
    Specified by:
      `describeContents` in interface `Parcelable`

  - ### writeToParcel

    public void writeToParcel(Parcel dest, int flags)
    Specified by:
      `writeToParcel` in interface `Parcelable`

  - ### hashCode

    public int hashCode()
    Overrides:
      `hashCode` in class `Object`

  - ### equals

    public boolean equals(Object obj)
    Overrides:
      `equals` in class `Object`