AssetLoader.Listener


public interface AssetLoader.Listener


A listener of AssetLoader events.

Summary

Public methods

abstract void
onDurationUs(long durationUs)

Called when the duration of the input media is known.

abstract void
onError(ExportException exportException)

Called if an error occurs in the asset loader.

abstract @Nullable SampleConsumer

Called when the Format of samples that will be output by the AssetLoader is known.

abstract boolean
onTrackAdded(
    Format inputFormat,
    @AssetLoader.SupportedOutputTypes int supportedOutputTypes
)

Called when the information on a track is known.

abstract void
onTrackCount(@IntRange(from = 1) int trackCount)

Called when the number of tracks being output is known.

Public methods

onDurationUs

abstract void onDurationUs(long durationUs)

Called when the duration of the input media is known.

Can be called from any thread.

onError

abstract void onError(ExportException exportException)

Called if an error occurs in the asset loader. In this case, the asset loader will be released automatically.

Can be called from any thread.

onOutputFormat

abstract @Nullable SampleConsumer onOutputFormat(Format format)

Called when the Format of samples that will be output by the AssetLoader is known.

Must be called after the corresponding track has been added.

For each added track, this method must be called regularly until the returned SampleConsumer is non-null.

Must be called from the thread that will be used to call the returned 's methods. This thread must be the same for all formats output, and is generally different from the one used to access the AssetLoader methods.

Parameters
Format format

The Format of samples that will be output.

Returns
@Nullable SampleConsumer

The SampleConsumer of samples of the given Format, or null if it could not be retrieved yet.

Throws
androidx.media3.transformer.ExportException

If an error occurs configuring the SampleConsumer.

onTrackAdded

abstract boolean onTrackAdded(
    Format inputFormat,
    @AssetLoader.SupportedOutputTypes int supportedOutputTypes
)

Called when the information on a track is known.

Must be called after the duration and the track count have been reported.

Must be called once per declared track.

Must be called from the thread that will be used to call onOutputFormat.

Parameters
Format inputFormat

The Format of samples that will be input to the (prior to video slow motion flattening or to decoding).

@AssetLoader.SupportedOutputTypes int supportedOutputTypes

The output types supported by this AssetLoader for the track added. At least one output type must be supported.

Returns
boolean

Whether the AssetLoader needs to provide decoded data to the .

onTrackCount

abstract void onTrackCount(@IntRange(from = 1) int trackCount)

Called when the number of tracks being output is known.

Can be called from any thread.