MediaItem.Builder
public final class MediaItem.Builder
A builder for MediaItem instances.
Summary
Public constructors |
|---|
Builder()Creates a builder. |
Public constructors
Public methods
setAdTagUri
@CanIgnoreReturnValue
@UnstableApi
public MediaItem.BuildersetAdTagUri(@Nullable String adTagUri)
setAdTagUri
@CanIgnoreReturnValue
@UnstableApi
public MediaItem.BuildersetAdTagUri(@Nullable Uri adTagUri)
setAdTagUri
@CanIgnoreReturnValue
@UnstableApi
public MediaItem.BuildersetAdTagUri(@Nullable Uri adTagUri, @Nullable Object adsId)
setAdsConfiguration
@CanIgnoreReturnValue
public MediaItem.Builder setAdsConfiguration(
@Nullable MediaItem.AdsConfiguration adsConfiguration
)
Sets the optional AdsConfiguration.
This method should only be called if setUri is passed a non-null value.
setClipEndPositionMs
@CanIgnoreReturnValue
@UnstableApi
public MediaItem.BuildersetClipEndPositionMs(long endPositionMs)
setClipRelativeToDefaultPosition
@CanIgnoreReturnValue
@UnstableApi
public MediaItem.BuildersetClipRelativeToDefaultPosition(boolean relativeToDefaultPosition)
setClipRelativeToLiveWindow
@CanIgnoreReturnValue
@UnstableApi
public MediaItem.BuildersetClipRelativeToLiveWindow(boolean relativeToLiveWindow)
setClipStartPositionMs
@CanIgnoreReturnValue
@UnstableApi
public MediaItem.BuildersetClipStartPositionMs(@IntRange(from = 0) long startPositionMs)
setClipStartsAtKeyFrame
@CanIgnoreReturnValue
@UnstableApi
public MediaItem.BuildersetClipStartsAtKeyFrame(boolean startsAtKeyFrame)
setClippingConfiguration
@CanIgnoreReturnValue
public MediaItem.Builder setClippingConfiguration(
MediaItem.ClippingConfiguration clippingConfiguration
)
Sets the ClippingConfiguration, defaults to UNSET.
setCustomCacheKey
@CanIgnoreReturnValue
@UnstableApi
public MediaItem.Builder setCustomCacheKey(@Nullable String customCacheKey)
Sets the optional custom cache key (only used for progressive streams).
This method should only be called if setUri is passed a non-null value.
setDrmConfiguration
@CanIgnoreReturnValue
public MediaItem.Builder setDrmConfiguration(
@Nullable MediaItem.DrmConfiguration drmConfiguration
)
Sets the optional DRM configuration.
setDrmForceDefaultLicenseUri
@CanIgnoreReturnValue
@UnstableApi
public MediaItem.BuildersetDrmForceDefaultLicenseUri(boolean forceDefaultLicenseUri)
setDrmKeySetId
@CanIgnoreReturnValue
@UnstableApi
public MediaItem.BuildersetDrmKeySetId(@Nullable byte[] keySetId)
setDrmLicenseRequestHeaders
@CanIgnoreReturnValue
@UnstableApi
public MediaItem.BuildersetDrmLicenseRequestHeaders(
@Nullable Map<String, String> licenseRequestHeaders
)
setDrmLicenseUri
@CanIgnoreReturnValue
@UnstableApi
public MediaItem.BuildersetDrmLicenseUri(@Nullable String licenseUri)
setDrmLicenseUri
@CanIgnoreReturnValue
@UnstableApi
public MediaItem.BuildersetDrmLicenseUri(@Nullable Uri licenseUri)
setDrmMultiSession
@CanIgnoreReturnValue
@UnstableApi
public MediaItem.BuildersetDrmMultiSession(boolean multiSession)
setDrmPlayClearContentWithoutKey
@CanIgnoreReturnValue
@UnstableApi
public MediaItem.BuildersetDrmPlayClearContentWithoutKey(boolean playClearContentWithoutKey)
setDrmSessionForClearPeriods
@CanIgnoreReturnValue
@UnstableApi
public MediaItem.BuildersetDrmSessionForClearPeriods(boolean sessionForClearPeriods)
setDrmSessionForClearTypes
@CanIgnoreReturnValue
@UnstableApi
public MediaItem.BuildersetDrmSessionForClearTypes(
@Nullable List<@C.TrackType Integer> sessionForClearTypes
)
setDrmUuid
@CanIgnoreReturnValue
@UnstableApi
public MediaItem.BuildersetDrmUuid(@Nullable UUID uuid)
setImageDurationMs
@CanIgnoreReturnValue
@UnstableApi
public MediaItem.Builder setImageDurationMs(long imageDurationMs)
Sets the image duration in video output, in milliseconds.
Should be set if the URI is set and resolves to an image, otherwise the duration of the image may default to a very small value. Ignored otherwise.
Motion photos will be rendered as images if this parameter is set, and as videos otherwise.
Default value is TIME_UNSET.
setLiveConfiguration
@CanIgnoreReturnValue
public MediaItem.Builder setLiveConfiguration(MediaItem.LiveConfiguration liveConfiguration)
Sets the LiveConfiguration. Defaults to UNSET.
setLiveMaxOffsetMs
@CanIgnoreReturnValue
@UnstableApi
public MediaItem.BuildersetLiveMaxOffsetMs(long liveMaxOffsetMs)
setLiveMaxPlaybackSpeed
@CanIgnoreReturnValue
@UnstableApi
public MediaItem.BuildersetLiveMaxPlaybackSpeed(float maxPlaybackSpeed)
setLiveMinOffsetMs
@CanIgnoreReturnValue
@UnstableApi
public MediaItem.BuildersetLiveMinOffsetMs(long liveMinOffsetMs)
setLiveMinPlaybackSpeed
@CanIgnoreReturnValue
@UnstableApi
public MediaItem.BuildersetLiveMinPlaybackSpeed(float minPlaybackSpeed)
setLiveTargetOffsetMs
@CanIgnoreReturnValue
@UnstableApi
public MediaItem.BuildersetLiveTargetOffsetMs(long liveTargetOffsetMs)
setMediaId
@CanIgnoreReturnValue
public MediaItem.Builder setMediaId(String mediaId)
Sets the optional media ID which identifies the media item.
By default DEFAULT_MEDIA_ID is used.
setMediaMetadata
@CanIgnoreReturnValue
public MediaItem.Builder setMediaMetadata(MediaMetadata mediaMetadata)
Sets the media metadata.
setMimeType
@CanIgnoreReturnValue
public MediaItem.Builder setMimeType(@Nullable String mimeType)
Sets the optional MIME type.
The MIME type may be used as a hint for inferring the type of the media item.
This method should only be called if setUri is passed a non-null value.
setRequestMetadata
@CanIgnoreReturnValue
public MediaItem.Builder setRequestMetadata(MediaItem.RequestMetadata requestMetadata)
Sets the request metadata.
setStreamKeys
@CanIgnoreReturnValue
@UnstableApi
public MediaItem.Builder setStreamKeys(@Nullable List<StreamKey> streamKeys)
Sets the optional stream keys by which the manifest is filtered (only used for adaptive streams).
null or an empty List can be used for a reset.
If setUri is passed a non-null uri, the stream keys are used to create a LocalConfiguration object. Otherwise they will be ignored.
setSubtitleConfigurations
@CanIgnoreReturnValue
public MediaItem.Builder setSubtitleConfigurations(
List<MediaItem.SubtitleConfiguration> subtitleConfigurations
)
Sets the optional subtitles.
This method should only be called if setUri is passed a non-null value.
setSubtitles
@CanIgnoreReturnValue
@UnstableApi
public MediaItem.BuildersetSubtitles(@Nullable List<MediaItem.Subtitle> subtitles)
setTag
@CanIgnoreReturnValue
public MediaItem.Builder setTag(@Nullable Object tag)
Sets the optional tag for custom attributes. The tag for the media source which will be published in the androidx.media3.common.Timeline of the source as
androidx.media3.common.Timeline.Window#tag.
This method should only be called if setUri is passed a non-null value.
setUri
@CanIgnoreReturnValue
public MediaItem.Builder setUri(@Nullable String uri)
Sets the optional URI.
If uri is null or unset then no LocalConfiguration object is created during build and no other Builder methods that would populate localConfiguration should be called.
setUri
@CanIgnoreReturnValue
public MediaItem.Builder setUri(@Nullable Uri uri)
Sets the optional URI.
If uri is null or unset then no LocalConfiguration object is created during build and no other Builder methods that would populate localConfiguration should be called.