SingleSampleMediaSource.Factory


public final class SingleSampleMediaSource.Factory


Factory for SingleSampleMediaSource.

Summary

Public constructors

Factory(DataSource.Factory dataSourceFactory)

Creates a factory for SingleSampleMediaSources.

Public methods

SingleSampleMediaSource
createMediaSource(
    MediaItem.SubtitleConfiguration subtitleConfiguration,
    long durationUs
)

Returns a new SingleSampleMediaSource using the current parameters.

SingleSampleMediaSource.Factory

Sets the LoadErrorHandlingPolicy.

SingleSampleMediaSource.Factory

Sets a tag for the media source which will be published in the Timeline of the source as Window#mediaItem.localConfiguration.tag.

SingleSampleMediaSource.Factory

This method is deprecated.

Use setId instead (on the MediaItem.SubtitleConfiguration passed to createMediaSource).

SingleSampleMediaSource.Factory
@CanIgnoreReturnValue
setTreatLoadErrorsAsEndOfStream(boolean treatLoadErrorsAsEndOfStream)

Sets whether load errors will be treated as end-of-stream signal (load errors will not be propagated).

Public constructors

Factory

public Factory(DataSource.Factory dataSourceFactory)

Creates a factory for SingleSampleMediaSources.

Parameters
DataSource.Factory dataSourceFactory

The factory from which the DataSource to read the media will be obtained.

Public methods

createMediaSource

public SingleSampleMediaSource createMediaSource(
    MediaItem.SubtitleConfiguration subtitleConfiguration,
    long durationUs
)

Returns a new SingleSampleMediaSource using the current parameters.

Parameters
MediaItem.SubtitleConfiguration subtitleConfiguration

The MediaItem.SubtitleConfiguration.

long durationUs

The duration of the media stream in microseconds.

setLoadErrorHandlingPolicy

@CanIgnoreReturnValue
public SingleSampleMediaSource.Factory setLoadErrorHandlingPolicy(
    @Nullable LoadErrorHandlingPolicy loadErrorHandlingPolicy
)

Sets the LoadErrorHandlingPolicy. The default value is created by calling DefaultLoadErrorHandlingPolicy.

Parameters
@Nullable LoadErrorHandlingPolicy loadErrorHandlingPolicy

A LoadErrorHandlingPolicy.

Returns
SingleSampleMediaSource.Factory

This factory, for convenience.

setTag

@CanIgnoreReturnValue
public SingleSampleMediaSource.Factory setTag(@Nullable Object tag)

Sets a tag for the media source which will be published in the Timeline of the source as Window#mediaItem.localConfiguration.tag.

Parameters
@Nullable Object tag

A tag for the media source.

Returns
SingleSampleMediaSource.Factory

This factory, for convenience.

setTrackId

@CanIgnoreReturnValue
public SingleSampleMediaSource.Factory setTrackId(@Nullable String trackId)

setTreatLoadErrorsAsEndOfStream

@CanIgnoreReturnValue
public SingleSampleMediaSource.Factory setTreatLoadErrorsAsEndOfStream(boolean treatLoadErrorsAsEndOfStream)

Sets whether load errors will be treated as end-of-stream signal (load errors will not be propagated). The default value is true.

Parameters
boolean treatLoadErrorsAsEndOfStream

If true, load errors will not be propagated by sample streams, treating them as ended instead. If false, load errors will be propagated normally by maybeThrowError.

Returns
SingleSampleMediaSource.Factory

This factory, for convenience.