Class ConcatenatingMediaSource2.Builder
- java.lang.Object
-
- com.google.android.exoplayer2.source.ConcatenatingMediaSource2.Builder
-
- Enclosing class:
- ConcatenatingMediaSource2
public static final class ConcatenatingMediaSource2.Builder extends Object
A builder forConcatenatingMediaSource2
instances.
-
-
Constructor Summary
Constructors Constructor Description Builder()
Creates the builder.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ConcatenatingMediaSource2.Builder
add(MediaItem mediaItem)
Adds aMediaItem
to the concatenation.ConcatenatingMediaSource2.Builder
add(MediaItem mediaItem, long initialPlaceholderDurationMs)
Adds aMediaItem
to the concatenation and specifies its initial placeholder duration used while the actual duration is still unknown.ConcatenatingMediaSource2.Builder
add(MediaSource mediaSource)
Adds aMediaSource
to the concatenation.ConcatenatingMediaSource2.Builder
add(MediaSource mediaSource, long initialPlaceholderDurationMs)
Adds aMediaSource
to the concatenation and specifies its initial placeholder duration used while the actual duration is still unknown.ConcatenatingMediaSource2
build()
Builds the concatenating media source.ConcatenatingMediaSource2.Builder
setMediaItem(MediaItem mediaItem)
Sets theMediaItem
to be used for the concatenated media source.ConcatenatingMediaSource2.Builder
setMediaSourceFactory(MediaSource.Factory mediaSourceFactory)
Sets aMediaSource.Factory
that is used to convertMediaItems
toMediaSources
for all future calls toadd(MediaItem)
oradd(MediaItem, long)
.ConcatenatingMediaSource2.Builder
useDefaultMediaSourceFactory(Context context)
Instructs the builder to use aDefaultMediaSourceFactory
to convertMediaItems
toMediaSources
for all future calls toadd(MediaItem)
oradd(MediaItem, long)
.
-
-
-
Method Detail
-
useDefaultMediaSourceFactory
@CanIgnoreReturnValue public ConcatenatingMediaSource2.Builder useDefaultMediaSourceFactory(Context context)
Instructs the builder to use aDefaultMediaSourceFactory
to convertMediaItems
toMediaSources
for all future calls toadd(MediaItem)
oradd(MediaItem, long)
.- Parameters:
context
- AContext
.- Returns:
- This builder.
-
setMediaSourceFactory
@CanIgnoreReturnValue public ConcatenatingMediaSource2.Builder setMediaSourceFactory(MediaSource.Factory mediaSourceFactory)
Sets aMediaSource.Factory
that is used to convertMediaItems
toMediaSources
for all future calls toadd(MediaItem)
oradd(MediaItem, long)
.- Parameters:
mediaSourceFactory
- AMediaSource.Factory
.- Returns:
- This builder.
-
setMediaItem
@CanIgnoreReturnValue public ConcatenatingMediaSource2.Builder setMediaItem(MediaItem mediaItem)
Sets theMediaItem
to be used for the concatenated media source.This
MediaItem
will be used asTimeline.Window.mediaItem
for the concatenated source and will be returned byPlayer.getCurrentMediaItem()
.The default is
MediaItem.fromUri(Uri.EMPTY)
.- Parameters:
mediaItem
- TheMediaItem
.- Returns:
- This builder.
-
add
@CanIgnoreReturnValue public ConcatenatingMediaSource2.Builder add(MediaItem mediaItem)
Adds aMediaItem
to the concatenation.useDefaultMediaSourceFactory(Context)
orsetMediaSourceFactory(MediaSource.Factory)
must be called before this method.This method must not be used with media items for progressive media that can't provide their duration with their first
Timeline
update. Useadd(MediaItem, long)
instead.- Parameters:
mediaItem
- TheMediaItem
.- Returns:
- This builder.
-
add
@CanIgnoreReturnValue public ConcatenatingMediaSource2.Builder add(MediaItem mediaItem, long initialPlaceholderDurationMs)
Adds aMediaItem
to the concatenation and specifies its initial placeholder duration used while the actual duration is still unknown.useDefaultMediaSourceFactory(Context)
orsetMediaSourceFactory(MediaSource.Factory)
must be called before this method.Setting a placeholder duration is required for media items for progressive media that can't provide their duration with their first
Timeline
update. It may also be used for other items to make the duration known immediately.- Parameters:
mediaItem
- TheMediaItem
.initialPlaceholderDurationMs
- The initial placeholder duration in milliseconds used while the actual duration is still unknown, orC.TIME_UNSET
to not define one. The placeholder duration is used for everyTimeline.Window
defined byTimeline
of theMediaItem
.- Returns:
- This builder.
-
add
@CanIgnoreReturnValue public ConcatenatingMediaSource2.Builder add(MediaSource mediaSource)
Adds aMediaSource
to the concatenation.This method must not be used for sources like
ProgressiveMediaSource
that can't provide their duration with their firstTimeline
update. Useadd(MediaSource, long)
instead.- Parameters:
mediaSource
- TheMediaSource
.- Returns:
- This builder.
-
add
@CanIgnoreReturnValue public ConcatenatingMediaSource2.Builder add(MediaSource mediaSource, long initialPlaceholderDurationMs)
Adds aMediaSource
to the concatenation and specifies its initial placeholder duration used while the actual duration is still unknown.Setting a placeholder duration is required for sources like
ProgressiveMediaSource
that can't provide their duration with their firstTimeline
update. It may also be used for other sources to make the duration known immediately.- Parameters:
mediaSource
- TheMediaSource
.initialPlaceholderDurationMs
- The initial placeholder duration in milliseconds used while the actual duration is still unknown, orC.TIME_UNSET
to not define one. The placeholder duration is used for everyTimeline.Window
defined byTimeline
of theMediaSource
.- Returns:
- This builder.
-
build
public ConcatenatingMediaSource2 build()
Builds the concatenating media source.
-
-