MediaItem.Builder


class MediaItem.Builder


A builder for MediaItem instances.

Summary

Public constructors

Creates a builder.

Public functions

MediaItem!

Returns a new MediaItem instance with the current builder values.

MediaItem.Builder!

This function is deprecated.

Use setAdsConfiguration, parse the adTagUri with parse and pass the result to Builder instead.

MediaItem.Builder!

This function is deprecated.

Use setAdsConfiguration and pass the adTagUri to Builder instead.

MediaItem.Builder!

This function is deprecated.

Use setAdsConfiguration, pass the adTagUri to Builder and the adsId to setAdsId instead.

MediaItem.Builder!

Sets the optional AdsConfiguration.

MediaItem.Builder!

This function is deprecated.

Use setClippingConfiguration and setEndPositionMs instead.

MediaItem.Builder!

This function is deprecated.

Use setClippingConfiguration and setRelativeToDefaultPosition instead.

MediaItem.Builder!

This function is deprecated.

Use setClippingConfiguration and setRelativeToLiveWindow instead.

MediaItem.Builder!

This function is deprecated.

Use setClippingConfiguration and setStartPositionMs instead.

MediaItem.Builder!

This function is deprecated.

Use setClippingConfiguration and setStartsAtKeyFrame instead.

MediaItem.Builder!

Sets the ClippingConfiguration, defaults to UNSET.

MediaItem.Builder!

Sets the optional custom cache key (only used for progressive streams).

MediaItem.Builder!

Sets the optional DRM configuration.

MediaItem.Builder!

This function is deprecated.

Use setDrmConfiguration and setForceDefaultLicenseUri instead.

MediaItem.Builder!

This function is deprecated.

Use setDrmConfiguration and setKeySetId instead.

MediaItem.Builder!

This function is deprecated.

Use setDrmConfiguration and setLicenseRequestHeaders instead.

MediaItem.Builder!

This function is deprecated.

Use setDrmConfiguration and setLicenseUri instead.

MediaItem.Builder!

This function is deprecated.

Use setDrmConfiguration and setLicenseUri instead.

MediaItem.Builder!

This function is deprecated.

Use setDrmConfiguration and setMultiSession instead.

MediaItem.Builder!

This function is deprecated.

Use setDrmConfiguration and setPlayClearContentWithoutKey instead.

MediaItem.Builder!

This function is deprecated.

Use setDrmConfiguration and setForceSessionsForAudioAndVideoTracks instead.

MediaItem.Builder!

This function is deprecated.

Use setDrmConfiguration and setForcedSessionTrackTypes instead.

MediaItem.Builder!

This function is deprecated.

Use setDrmConfiguration and pass the uuid to Builder instead.

MediaItem.Builder!

Sets the image duration in video output, in milliseconds.

MediaItem.Builder!

Sets the LiveConfiguration.

MediaItem.Builder!

This function is deprecated.

Use setLiveConfiguration and setMaxOffsetMs.

MediaItem.Builder!

This function is deprecated.

Use setLiveConfiguration and setMaxPlaybackSpeed.

MediaItem.Builder!

This function is deprecated.

Use setLiveConfiguration and setMinOffsetMs.

MediaItem.Builder!

This function is deprecated.

Use setLiveConfiguration and setMinPlaybackSpeed.

MediaItem.Builder!

This function is deprecated.

Use setLiveConfiguration and setTargetOffsetMs.

MediaItem.Builder!

Sets the optional media ID which identifies the media item.

MediaItem.Builder!

Sets the media metadata.

MediaItem.Builder!

Sets the optional MIME type.

MediaItem.Builder!

Sets the request metadata.

MediaItem.Builder!

Sets the optional stream keys by which the manifest is filtered (only used for adaptive streams).

MediaItem.Builder!

Sets the optional subtitles.

MediaItem.Builder!

This function is deprecated.

Use setSubtitleConfigurations instead.

MediaItem.Builder!

Sets the optional tag for custom attributes.

MediaItem.Builder!

Sets the optional URI.

MediaItem.Builder!

Sets the optional URI.

Public constructors

Builder

Builder()

Creates a builder.

Public functions

build

fun build(): MediaItem!

Returns a new MediaItem instance with the current builder values.

setAdTagUri

@CanIgnoreReturnValue
@UnstableApi
fun setAdTagUri(adTagUri: String?): MediaItem.Builder!

setAdTagUri

@CanIgnoreReturnValue
@UnstableApi
fun setAdTagUri(adTagUri: Uri?): MediaItem.Builder!

setAdTagUri

@CanIgnoreReturnValue
@UnstableApi
fun setAdTagUri(adTagUri: Uri?, adsId: Any?): MediaItem.Builder!

setAdsConfiguration

@CanIgnoreReturnValue
fun setAdsConfiguration(adsConfiguration: MediaItem.AdsConfiguration?): MediaItem.Builder!

Sets the optional AdsConfiguration.

This method should only be called if setUri is passed a non-null value.

setClipEndPositionMs

@CanIgnoreReturnValue
@UnstableApi
fun setClipEndPositionMs(endPositionMs: Long): MediaItem.Builder!

setClipRelativeToDefaultPosition

@CanIgnoreReturnValue
@UnstableApi
fun setClipRelativeToDefaultPosition(relativeToDefaultPosition: Boolean): MediaItem.Builder!

setClipRelativeToLiveWindow

@CanIgnoreReturnValue
@UnstableApi
fun setClipRelativeToLiveWindow(relativeToLiveWindow: Boolean): MediaItem.Builder!

setClipStartPositionMs

@CanIgnoreReturnValue
@UnstableApi
fun setClipStartPositionMs(startPositionMs: @IntRange(from = 0) Long): MediaItem.Builder!

setClipStartsAtKeyFrame

@CanIgnoreReturnValue
@UnstableApi
fun setClipStartsAtKeyFrame(startsAtKeyFrame: Boolean): MediaItem.Builder!

setClippingConfiguration

@CanIgnoreReturnValue
fun setClippingConfiguration(
    clippingConfiguration: MediaItem.ClippingConfiguration!
): MediaItem.Builder!

Sets the ClippingConfiguration, defaults to UNSET.

setCustomCacheKey

@CanIgnoreReturnValue
@UnstableApi
fun setCustomCacheKey(customCacheKey: String?): MediaItem.Builder!

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
fun setDrmConfiguration(drmConfiguration: MediaItem.DrmConfiguration?): MediaItem.Builder!

Sets the optional DRM configuration.

setDrmForceDefaultLicenseUri

@CanIgnoreReturnValue
@UnstableApi
fun setDrmForceDefaultLicenseUri(forceDefaultLicenseUri: Boolean): MediaItem.Builder!

setDrmKeySetId

@CanIgnoreReturnValue
@UnstableApi
fun setDrmKeySetId(keySetId: ByteArray?): MediaItem.Builder!

setDrmLicenseRequestHeaders

@CanIgnoreReturnValue
@UnstableApi
fun setDrmLicenseRequestHeaders(
    licenseRequestHeaders: (Mutable)Map<String!, String!>?
): MediaItem.Builder!

setDrmLicenseUri

@CanIgnoreReturnValue
@UnstableApi
fun setDrmLicenseUri(licenseUri: String?): MediaItem.Builder!

setDrmLicenseUri

@CanIgnoreReturnValue
@UnstableApi
fun setDrmLicenseUri(licenseUri: Uri?): MediaItem.Builder!

setDrmMultiSession

@CanIgnoreReturnValue
@UnstableApi
fun setDrmMultiSession(multiSession: Boolean): MediaItem.Builder!

setDrmPlayClearContentWithoutKey

@CanIgnoreReturnValue
@UnstableApi
fun setDrmPlayClearContentWithoutKey(playClearContentWithoutKey: Boolean): MediaItem.Builder!

setDrmSessionForClearPeriods

@CanIgnoreReturnValue
@UnstableApi
fun setDrmSessionForClearPeriods(sessionForClearPeriods: Boolean): MediaItem.Builder!

setDrmSessionForClearTypes

@CanIgnoreReturnValue
@UnstableApi
fun setDrmSessionForClearTypes(
    sessionForClearTypes: (Mutable)List<@C.TrackType Int!>?
): MediaItem.Builder!

setDrmUuid

@CanIgnoreReturnValue
@UnstableApi
fun setDrmUuid(uuid: UUID?): MediaItem.Builder!

setImageDurationMs

@CanIgnoreReturnValue
@UnstableApi
fun setImageDurationMs(imageDurationMs: Long): MediaItem.Builder!

Sets the image duration in video output, in milliseconds.

Must be set if the URI is set and resolves to an image. 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
fun setLiveConfiguration(liveConfiguration: MediaItem.LiveConfiguration!): MediaItem.Builder!

Sets the LiveConfiguration. Defaults to UNSET.

setLiveMaxOffsetMs

@CanIgnoreReturnValue
@UnstableApi
fun setLiveMaxOffsetMs(liveMaxOffsetMs: Long): MediaItem.Builder!

setLiveMaxPlaybackSpeed

@CanIgnoreReturnValue
@UnstableApi
fun setLiveMaxPlaybackSpeed(maxPlaybackSpeed: Float): MediaItem.Builder!

setLiveMinOffsetMs

@CanIgnoreReturnValue
@UnstableApi
fun setLiveMinOffsetMs(liveMinOffsetMs: Long): MediaItem.Builder!

setLiveMinPlaybackSpeed

@CanIgnoreReturnValue
@UnstableApi
fun setLiveMinPlaybackSpeed(minPlaybackSpeed: Float): MediaItem.Builder!

setLiveTargetOffsetMs

@CanIgnoreReturnValue
@UnstableApi
fun setLiveTargetOffsetMs(liveTargetOffsetMs: Long): MediaItem.Builder!

setMediaId

@CanIgnoreReturnValue
fun setMediaId(mediaId: String!): MediaItem.Builder!

Sets the optional media ID which identifies the media item.

By default DEFAULT_MEDIA_ID is used.

setMediaMetadata

@CanIgnoreReturnValue
fun setMediaMetadata(mediaMetadata: MediaMetadata!): MediaItem.Builder!

Sets the media metadata.

setMimeType

@CanIgnoreReturnValue
fun setMimeType(mimeType: String?): MediaItem.Builder!

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.

Parameters
mimeType: String?

The MIME type.

setRequestMetadata

@CanIgnoreReturnValue
fun setRequestMetadata(requestMetadata: MediaItem.RequestMetadata!): MediaItem.Builder!

Sets the request metadata.

setStreamKeys

@CanIgnoreReturnValue
@UnstableApi
fun setStreamKeys(streamKeys: (Mutable)List<StreamKey!>?): MediaItem.Builder!

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
fun setSubtitleConfigurations(
    subtitleConfigurations: (Mutable)List<MediaItem.SubtitleConfiguration!>!
): MediaItem.Builder!

Sets the optional subtitles.

This method should only be called if setUri is passed a non-null value.

setSubtitles

@CanIgnoreReturnValue
@UnstableApi
fun setSubtitles(subtitles: (Mutable)List<MediaItem.Subtitle!>?): MediaItem.Builder!

setTag

@CanIgnoreReturnValue
fun setTag(tag: Any?): MediaItem.Builder!

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
fun setUri(uri: String?): MediaItem.Builder!

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
fun setUri(uri: Uri?): MediaItem.Builder!

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.