Constructor | Description |
---|---|
Builder() |
Creates a builder.
|
Modifier and Type | Method | Description |
---|---|---|
MediaItem |
build() |
Returns a new
MediaItem instance with the current builder values. |
MediaItem.Builder |
setAdTagUri(Uri adTagUri) |
Sets the optional ad tag
Uri . |
MediaItem.Builder |
setAdTagUri(Uri adTagUri,
Object adsId) |
Sets the optional ad tag
Uri and ads identifier. |
MediaItem.Builder |
setAdTagUri(String adTagUri) |
Sets the optional ad tag
Uri . |
MediaItem.Builder |
setClipEndPositionMs(long endPositionMs) |
Sets the optional end position in milliseconds which must be a value larger than or equal to
zero, or
C.TIME_END_OF_SOURCE to end when playback reaches the end of media (Default:
C.TIME_END_OF_SOURCE ). |
MediaItem.Builder |
setClipRelativeToDefaultPosition(boolean relativeToDefaultPosition) |
Sets whether the start position and the end position are relative to the default position in
the window (Default:
false ). |
MediaItem.Builder |
setClipRelativeToLiveWindow(boolean relativeToLiveWindow) |
Sets whether the start/end positions should move with the live window for live streams.
|
MediaItem.Builder |
setClipStartPositionMs(long startPositionMs) |
Sets the optional start position in milliseconds which must be a value larger than or equal
to zero (Default: 0).
|
MediaItem.Builder |
setClipStartsAtKeyFrame(boolean startsAtKeyFrame) |
Sets whether the start point is guaranteed to be a key frame.
|
MediaItem.Builder |
setCustomCacheKey(String customCacheKey) |
Sets the optional custom cache key (only used for progressive streams).
|
MediaItem.Builder |
setDrmForceDefaultLicenseUri(boolean forceDefaultLicenseUri) |
Sets whether to force use the default DRM license server URI even if the media specifies its
own DRM license server URI.
|
MediaItem.Builder |
setDrmKeySetId(byte[] keySetId) |
Sets the key set ID of the offline license.
|
MediaItem.Builder |
setDrmLicenseRequestHeaders(Map<String,String> licenseRequestHeaders) |
Sets the optional request headers attached to the DRM license request.
|
MediaItem.Builder |
setDrmLicenseUri(Uri licenseUri) |
Sets the optional default DRM license server URI.
|
MediaItem.Builder |
setDrmLicenseUri(String licenseUri) |
Sets the optional default DRM license server URI.
|
MediaItem.Builder |
setDrmMultiSession(boolean multiSession) |
Sets whether the DRM configuration is multi session enabled.
|
MediaItem.Builder |
setDrmPlayClearContentWithoutKey(boolean playClearContentWithoutKey) |
Sets whether clear samples within protected content should be played when keys for the
encrypted part of the content have yet to be loaded.
|
MediaItem.Builder |
setDrmSessionForClearPeriods(boolean sessionForClearPeriods) |
Sets whether a DRM session should be used for clear tracks of type
C.TRACK_TYPE_VIDEO
and C.TRACK_TYPE_AUDIO . |
MediaItem.Builder |
setDrmSessionForClearTypes(List<Integer> sessionForClearTypes) |
Sets a list of
C .TRACK_TYPE_* constants for which to use a DRM session even
when the tracks are in the clear. |
MediaItem.Builder |
setDrmUuid(UUID uuid) |
Sets the
UUID of the protection scheme. |
MediaItem.Builder |
setLiveMaxOffsetMs(long liveMaxOffsetMs) |
Sets the optional maximum offset from the live edge for live streams, in milliseconds.
|
MediaItem.Builder |
setLiveMaxPlaybackSpeed(float maxPlaybackSpeed) |
Sets the optional maximum playback speed for live stream speed adjustment.
|
MediaItem.Builder |
setLiveMinOffsetMs(long liveMinOffsetMs) |
Sets the optional minimum offset from the live edge for live streams, in milliseconds.
|
MediaItem.Builder |
setLiveMinPlaybackSpeed(float minPlaybackSpeed) |
Sets the optional minimum playback speed for live stream speed adjustment.
|
MediaItem.Builder |
setLiveTargetOffsetMs(long liveTargetOffsetMs) |
Sets the optional target offset from the live edge for live streams, in milliseconds.
|
MediaItem.Builder |
setMediaId(String mediaId) |
Sets the optional media ID which identifies the media item.
|
MediaItem.Builder |
setMediaMetadata(MediaMetadata mediaMetadata) |
Sets the media metadata.
|
MediaItem.Builder |
setMimeType(String mimeType) |
Sets the optional MIME type.
|
MediaItem.Builder |
setStreamKeys(List<StreamKey> streamKeys) |
Sets the optional stream keys by which the manifest is filtered (only used for adaptive
streams).
|
MediaItem.Builder |
setSubtitles(List<MediaItem.Subtitle> subtitles) |
Sets the optional subtitles.
|
MediaItem.Builder |
setTag(Object tag) |
Sets the optional tag for custom attributes.
|
MediaItem.Builder |
setUri(Uri uri) |
Sets the optional URI.
|
MediaItem.Builder |
setUri(String uri) |
Sets the optional URI.
|
public MediaItem.Builder setMediaId(@Nullable String mediaId)
setUri(java.lang.String)
must be called and the string representation of MediaItem.PlaybackProperties.uri
is used as the
media ID.public MediaItem.Builder setUri(@Nullable String uri)
setMediaId(String)
must be called.
If uri
is null or unset no MediaItem.PlaybackProperties
object is created during
build()
and any other Builder
methods that would populate MediaItem.playbackProperties
are ignored.
public MediaItem.Builder setUri(@Nullable Uri uri)
setMediaId(String)
must be called.
If uri
is null or unset no MediaItem.PlaybackProperties
object is created during
build()
and any other Builder
methods that would populate MediaItem.playbackProperties
are ignored.
public MediaItem.Builder setMimeType(@Nullable String mimeType)
The MIME type may be used as a hint for inferring the type of the media item.
If setUri(java.lang.String)
is passed a non-null uri
, the MIME type is used to create a
MediaItem.PlaybackProperties
object. Otherwise it will be ignored.
mimeType
- The MIME type.public MediaItem.Builder setClipStartPositionMs(long startPositionMs)
public MediaItem.Builder setClipEndPositionMs(long endPositionMs)
C.TIME_END_OF_SOURCE
to end when playback reaches the end of media (Default:
C.TIME_END_OF_SOURCE
).public MediaItem.Builder setClipRelativeToLiveWindow(boolean relativeToLiveWindow)
false
, live streams end when playback reaches the end position in live window seen
when the media is first loaded (Default: false
).public MediaItem.Builder setClipRelativeToDefaultPosition(boolean relativeToDefaultPosition)
false
).public MediaItem.Builder setClipStartsAtKeyFrame(boolean startsAtKeyFrame)
false
, the playback
transition into the clip may not be seamless (Default: false
).public MediaItem.Builder setDrmLicenseUri(@Nullable Uri licenseUri)
MediaItem.DrmConfiguration.uuid
needs to be specified as well.
If setUri(java.lang.String)
is passed a non-null uri
, the DRM license server URI is used to
create a MediaItem.PlaybackProperties
object. Otherwise it will be ignored.
public MediaItem.Builder setDrmLicenseUri(@Nullable String licenseUri)
MediaItem.DrmConfiguration.uuid
needs to be specified as well.
If setUri(java.lang.String)
is passed a non-null uri
, the DRM license server URI is used to
create a MediaItem.PlaybackProperties
object. Otherwise it will be ignored.
public MediaItem.Builder setDrmLicenseRequestHeaders(@Nullable Map<String,String> licenseRequestHeaders)
null
or an empty Map
can be used for a reset.
If no valid DRM configuration is specified, the DRM license request headers are ignored.
public MediaItem.Builder setDrmUuid(@Nullable UUID uuid)
UUID
of the protection scheme. If a DRM system UUID is set, the MediaItem.DrmConfiguration.licenseUri
needs to be set as well.
If setUri(java.lang.String)
is passed a non-null uri
, the DRM system UUID is used to create
a MediaItem.PlaybackProperties
object. Otherwise it will be ignored.
public MediaItem.Builder setDrmMultiSession(boolean multiSession)
If setUri(java.lang.String)
is passed a non-null uri
, the DRM multi session flag is used to
create a MediaItem.PlaybackProperties
object. Otherwise it will be ignored.
public MediaItem.Builder setDrmForceDefaultLicenseUri(boolean forceDefaultLicenseUri)
If setUri(java.lang.String)
is passed a non-null uri
, the DRM force default license flag is
used to create a MediaItem.PlaybackProperties
object. Otherwise it will be ignored.
public MediaItem.Builder setDrmPlayClearContentWithoutKey(boolean playClearContentWithoutKey)
public MediaItem.Builder setDrmSessionForClearPeriods(boolean sessionForClearPeriods)
C.TRACK_TYPE_VIDEO
and C.TRACK_TYPE_AUDIO
.
This method overrides what has been set by previously calling setDrmSessionForClearTypes(List)
.
public MediaItem.Builder setDrmSessionForClearTypes(@Nullable List<Integer> sessionForClearTypes)
C
.TRACK_TYPE_*
constants for which to use a DRM session even
when the tracks are in the clear.
For the common case of using a DRM session for C.TRACK_TYPE_VIDEO
and C.TRACK_TYPE_AUDIO
the setDrmSessionForClearPeriods(boolean)
can be used.
This method overrides what has been set by previously calling setDrmSessionForClearPeriods(boolean)
.
null
or an empty List
can be used for a reset.
public MediaItem.Builder setDrmKeySetId(@Nullable byte[] keySetId)
The key set ID identifies an offline license. The ID is required to query, renew or
release an existing offline license (see DefaultDrmSessionManager#setMode(int
mode,byte[] offlineLicenseKeySetId)
).
If no valid DRM configuration is specified, the key set ID is ignored.
public MediaItem.Builder setStreamKeys(@Nullable List<StreamKey> streamKeys)
null
or an empty List
can be used for a reset.
If setUri(java.lang.String)
is passed a non-null uri
, the stream keys are used to create a
MediaItem.PlaybackProperties
object. Otherwise they will be ignored.
public MediaItem.Builder setCustomCacheKey(@Nullable String customCacheKey)
If setUri(java.lang.String)
is passed a non-null uri
, the custom cache key is used to
create a MediaItem.PlaybackProperties
object. Otherwise it will be ignored.
public MediaItem.Builder setSubtitles(@Nullable List<MediaItem.Subtitle> subtitles)
null
or an empty List
can be used for a reset.
If setUri(java.lang.String)
is passed a non-null uri
, the subtitles are used to create a
MediaItem.PlaybackProperties
object. Otherwise they will be ignored.
public MediaItem.Builder setAdTagUri(@Nullable String adTagUri)
Uri
.
If setUri(java.lang.String)
is passed a non-null uri
, the ad tag URI is used to create a
MediaItem.PlaybackProperties
object. Otherwise it will be ignored.
Media items in the playlist with the same ad tag URI, media ID and ads loader will share the same ad playback state. To resume ad playback when recreating the playlist on returning from the background, pass media items with the same ad tag URIs and media IDs to the player.
adTagUri
- The ad tag URI to load.public MediaItem.Builder setAdTagUri(@Nullable Uri adTagUri)
Uri
.
If setUri(java.lang.String)
is passed a non-null uri
, the ad tag URI is used to create a
MediaItem.PlaybackProperties
object. Otherwise it will be ignored.
Media items in the playlist with the same ad tag URI, media ID and ads loader will share the same ad playback state. To resume ad playback when recreating the playlist on returning from the background, pass media items with the same ad tag URIs and media IDs to the player.
adTagUri
- The ad tag URI to load.public MediaItem.Builder setAdTagUri(@Nullable Uri adTagUri, @Nullable Object adsId)
Uri
and ads identifier.
If setUri(java.lang.String)
is passed a non-null uri
, the ad tag URI is used to create a
MediaItem.PlaybackProperties
object. Otherwise it will be ignored.
Media items in the playlist that have the same ads identifier and ads loader share the same ad playback state. To resume ad playback when recreating the playlist on returning from the background, pass the same ads IDs to the player.
adTagUri
- The ad tag URI to load.adsId
- An opaque identifier for ad playback state associated with this item. Ad loading
and playback state is shared among all media items that have the same ads ID (by equality
) and ads loader, so it is important to pass the same
identifiers when constructing playlist items each time the player returns to the
foreground.public MediaItem.Builder setLiveTargetOffsetMs(long liveTargetOffsetMs)
See Player#getCurrentLiveOffset()
.
liveTargetOffsetMs
- The target offset, in milliseconds, or C.TIME_UNSET
to use
the media-defined default.public MediaItem.Builder setLiveMinOffsetMs(long liveMinOffsetMs)
See Player#getCurrentLiveOffset()
.
liveMinOffsetMs
- The minimum allowed offset, in milliseconds, or C.TIME_UNSET
to use the media-defined default.public MediaItem.Builder setLiveMaxOffsetMs(long liveMaxOffsetMs)
See Player#getCurrentLiveOffset()
.
liveMaxOffsetMs
- The maximum allowed offset, in milliseconds, or C.TIME_UNSET
to use the media-defined default.public MediaItem.Builder setLiveMinPlaybackSpeed(float minPlaybackSpeed)
This value is ignored for other stream types.
minPlaybackSpeed
- The minimum factor by which playback can be sped up for live streams,
or C.RATE_UNSET
to use the media-defined default.public MediaItem.Builder setLiveMaxPlaybackSpeed(float maxPlaybackSpeed)
This value is ignored for other stream types.
maxPlaybackSpeed
- The maximum factor by which playback can be sped up for live streams,
or C.RATE_UNSET
to use the media-defined default.public MediaItem.Builder setTag(@Nullable Object tag)
com.google.android.exoplayer2.Timeline
of the source as
com.google.android.exoplayer2.Timeline.Window#tag
.
If setUri(java.lang.String)
is passed a non-null uri
, the tag is used to create a MediaItem.PlaybackProperties
object. Otherwise it will be ignored.
public MediaItem.Builder setMediaMetadata(MediaMetadata mediaMetadata)