MediaSourcepublic final class SilenceMediaSource extends BaseMediaSource
| Modifier and Type | Class | Description |
|---|---|---|
static class |
SilenceMediaSource.Factory |
Factory for
SilenceMediaSources. |
MediaSource.MediaPeriodId, MediaSource.MediaSourceCaller| Modifier and Type | Field | Description |
|---|---|---|
static String |
MEDIA_ID |
The media id used by any media item of silence media sources.
|
| Constructor | Description |
|---|---|
SilenceMediaSource(long durationUs) |
Creates a new media source providing silent audio of the given duration.
|
| Modifier and Type | Method | Description |
|---|---|---|
MediaPeriod |
createPeriod(MediaSource.MediaPeriodId id,
Allocator allocator,
long startPositionUs) |
Returns a new
MediaPeriod identified by periodId. |
MediaItem |
getMediaItem() |
Returns the
MediaItem whose media is provided by the source. |
Object |
getTag() |
Deprecated.
Use
getMediaItem() and MediaItem.PlaybackProperties.tag instead. |
void |
maybeThrowSourceInfoRefreshError() |
Throws any pending error encountered while loading or refreshing source information.
|
protected void |
prepareSourceInternal(TransferListener mediaTransferListener) |
Starts source preparation and enables the source, see
BaseMediaSource.prepareSource(MediaSourceCaller,
TransferListener). |
void |
releasePeriod(MediaPeriod mediaPeriod) |
Releases the period.
|
protected void |
releaseSourceInternal() |
Releases the source, see
BaseMediaSource.releaseSource(MediaSourceCaller). |
addDrmEventListener, addEventListener, createDrmEventDispatcher, createDrmEventDispatcher, createEventDispatcher, createEventDispatcher, createEventDispatcher, disable, disableInternal, enable, enableInternal, isEnabled, prepareSource, refreshSourceInfo, releaseSource, removeDrmEventListener, removeEventListenergetInitialTimeline, isSingleWindowpublic static final String MEDIA_ID
public SilenceMediaSource(long durationUs)
durationUs - The duration of silent audio to output, in microseconds.protected void prepareSourceInternal(@Nullable
TransferListener mediaTransferListener)
BaseMediaSourceBaseMediaSource.prepareSource(MediaSourceCaller,
TransferListener). This method is called at most once until the next call to BaseMediaSource.releaseSourceInternal().prepareSourceInternal in class BaseMediaSourcemediaTransferListener - The transfer listener which should be informed of any media data
transfers. May be null if no listener is available. Note that this listener should usually
be only informed of transfers related to the media loads and not of auxiliary loads for
manifests and other data.public void maybeThrowSourceInfoRefreshError()
MediaSourceShould not be called directly from application code.
Must only be called after MediaSource.prepareSource(MediaSourceCaller, TransferListener).
public MediaPeriod createPeriod(MediaSource.MediaPeriodId id, Allocator allocator, long startPositionUs)
MediaSourceMediaPeriod identified by periodId.
Should not be called directly from application code.
Must only be called if the source is enabled.
id - The identifier of the period.allocator - An Allocator from which to obtain media buffer allocations.startPositionUs - The expected start position, in microseconds.MediaPeriod.public void releasePeriod(MediaPeriod mediaPeriod)
MediaSourceShould not be called directly from application code.
mediaPeriod - The period to release.@Deprecated @Nullable public Object getTag()
getMediaItem() and MediaItem.PlaybackProperties.tag instead.public MediaItem getMediaItem()
MediaSourceMediaItem whose media is provided by the source.protected void releaseSourceInternal()
BaseMediaSourceBaseMediaSource.releaseSource(MediaSourceCaller). This method is called
exactly once after each call to BaseMediaSource.prepareSourceInternal(TransferListener).releaseSourceInternal in class BaseMediaSource