Stay organized with collections Save and categorize content based on your preferences.

ImaServerSideAdInsertionMediaSource

@UnstableApi
public final class ImaServerSideAdInsertionMediaSource extends CompositeMediaSource


MediaSource for IMA server side inserted ad streams.

Summary

Nested types

public final class ImaServerSideAdInsertionMediaSource.AdsLoader

An ads loader for IMA server side ad insertion streams.

public final class ImaServerSideAdInsertionMediaSource.AdsLoader.Builder

Builder for building an AdsLoader.

public class ImaServerSideAdInsertionMediaSource.AdsLoader.State implements Bundleable

The state of the AdsLoader that can be used when resuming from the background.

public final class ImaServerSideAdInsertionMediaSource.Factory implements MediaSource.Factory

Factory for creating ImaServerSideAdInsertionMediaSources.

Public fields

final MediaItem

Public constructors

Public methods

MediaPeriod
createPeriod(
    MediaSource.MediaPeriodId id,
    Allocator allocator,
    long startPositionUs
)

Returns a new MediaPeriod identified by periodId.

MediaItem

Returns the MediaItem whose media is provided by the source.

void

Throws any pending error encountered while loading or refreshing source information.

void

Starts source preparation and enables the source, see prepareSource.

void

Releases the period.

Protected methods

void
onChildSourceInfoRefreshed(
    Void childSourceId,
    MediaSource mediaSource,
    Timeline newTimeline
)

Called when the source info of a child source has been refreshed.

void

Releases the source, see releaseSource.

Inherited methods

From androidx.media3.exoplayer.source.BaseMediaSource
final void
addDrmEventListener(
    Handler handler,
    DrmSessionEventListener eventListener
)

Adds a DrmSessionEventListener to the list of listeners which are notified of DRM events for this media source.

final void
addEventListener(
    Handler handler,
    MediaSourceEventListener eventListener
)

Adds a MediaSourceEventListener to the list of listeners which are notified of media source events.

final DrmSessionEventListener.EventDispatcher

Returns a DrmSessionEventListener.EventDispatcher which dispatches all events to the registered listeners with the specified MediaPeriodId

final DrmSessionEventListener.EventDispatcher
createDrmEventDispatcher(
    int windowIndex,
    @Nullable MediaSource.MediaPeriodId mediaPeriodId
)

Returns a DrmSessionEventListener.EventDispatcher which dispatches all events to the registered listeners with the specified window index and MediaPeriodId.

final MediaSourceEventListener.EventDispatcher

Returns a MediaSourceEventListener.EventDispatcher which dispatches all events to the registered listeners with the specified MediaPeriodId.

final MediaSourceEventListener.EventDispatcher
createEventDispatcher(
    MediaSource.MediaPeriodId mediaPeriodId,
    long mediaTimeOffsetMs
)

Returns a MediaSourceEventListener.EventDispatcher which dispatches all events to the registered listeners with the specified MediaPeriodId and time offset.

final MediaSourceEventListener.EventDispatcher
createEventDispatcher(
    int windowIndex,
    @Nullable MediaSource.MediaPeriodId mediaPeriodId,
    long mediaTimeOffsetMs
)

Returns a MediaSourceEventListener.EventDispatcher which dispatches all events to the registered listeners with the specified window index, MediaPeriodId and time offset.

final void

Disables the source for the creation of MediaPeriods.

final void

Enables the source for the creation of MediaPeriods.

final PlayerId

Returns the PlayerId of the player using this media source.

final boolean

Returns whether the source is enabled.

final void
prepareSource(
    MediaSource.MediaSourceCaller caller,
    @Nullable TransferListener mediaTransferListener
)

This method is deprecated.

Implement prepareSource instead.

final void
prepareSource(
    MediaSource.MediaSourceCaller caller,
    @Nullable TransferListener mediaTransferListener,
    PlayerId playerId
)

Registers a MediaSourceCaller.

final void

Updates timeline and manifest and notifies all listeners of the update.

final void

Unregisters a caller, and disables and releases the source if no longer required.

final void

Removes a DrmSessionEventListener from the list of listeners which are notified of DRM events for this media source.

final void

Removes a MediaSourceEventListener from the list of listeners which are notified of media source events.

From androidx.media3.exoplayer.source.CompositeMediaSource
final void

Disables a child source.

void

Disables the source, see disable.

final void

Enables a child source.

void

Enables the source, see enable.

@Nullable MediaSource.MediaPeriodId
getMediaPeriodIdForChildMediaPeriodId(
    @UnknownNull T childSourceId,
    MediaSource.MediaPeriodId mediaPeriodId
)

Returns the MediaPeriodId in the composite source corresponding to the specified in a child source.

long
getMediaTimeForChildMediaTime(
    @UnknownNull T childSourceId,
    long mediaTimeMs
)

Returns the media time in the MediaPeriod of the composite source corresponding to the specified media time in the MediaPeriod of the child source.

int
getWindowIndexForChildWindowIndex(
    @UnknownNull T childSourceId,
    int windowIndex
)

Returns the window index in the composite source corresponding to the specified window index in a child source.

final void

Prepares a child source.

final void

Releases a child source.

From androidx.media3.exoplayer.source.MediaSource
@Nullable Timeline

Returns the initial placeholder timeline that is returned immediately when the real timeline is not yet known, or null to let the player create an initial timeline.

boolean

Returns true if the media source is guaranteed to never have zero or more than one window.

Public fields

mediaItem

public final MediaItem mediaItem

Public constructors

ImaServerSideAdInsertionMediaSource

public ImaServerSideAdInsertionMediaSource()

Public methods

createPeriod

public MediaPeriod createPeriod(
    MediaSource.MediaPeriodId id,
    Allocator allocator,
    long startPositionUs
)

Returns a new MediaPeriod identified by periodId.

Should not be called directly from application code.

Must only be called if the source is enabled.

Parameters
MediaSource.MediaPeriodId id

The identifier of the period.

Allocator allocator

An Allocator from which to obtain media buffer allocations.

long startPositionUs

The expected start position, in microseconds.

Returns
MediaPeriod

A new MediaPeriod.

getMediaItem

public MediaItem getMediaItem()

Returns the MediaItem whose media is provided by the source.

maybeThrowSourceInfoRefreshError

public void maybeThrowSourceInfoRefreshError()

Throws any pending error encountered while loading or refreshing source information.

Should not be called directly from application code.

Must only be called after prepareSource.

Throws
java.io.IOException java.io.IOException

prepareSourceInternal

public void prepareSourceInternal(@Nullable TransferListener mediaTransferListener)

Starts source preparation and enables the source, see prepareSource. This method is called at most once until the next call to releaseSourceInternal.

Parameters
@Nullable TransferListener mediaTransferListener

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.

releasePeriod

public void releasePeriod(MediaPeriod mediaPeriod)

Releases the period.

Should not be called directly from application code.

Parameters
MediaPeriod mediaPeriod

The period to release.

Protected methods

onChildSourceInfoRefreshed

protected void onChildSourceInfoRefreshed(
    Void childSourceId,
    MediaSource mediaSource,
    Timeline newTimeline
)

Called when the source info of a child source has been refreshed.

Parameters
Void childSourceId

The unique id used to prepare the child source.

MediaSource mediaSource

The child source whose source info has been refreshed.

Timeline newTimeline

The timeline of the child source.

releaseSourceInternal

protected void releaseSourceInternal()

Releases the source, see releaseSource. This method is called exactly once after each call to prepareSourceInternal.