# AssetLoader.Listener

Artifact: [androidx.media3:media3-transformer](https://developer.android.com/jetpack/androidx/releases/media3) [View Source](https://cs.android.com/search?q=file:androidx/media3/transformer/AssetLoader.java+class:androidx.media3.transformer.AssetLoader.Listener)

*** ** * ** ***


```
public interface AssetLoader.Listener
```

<br />

*** ** * ** ***

A listener of `https://developer.android.com/reference/androidx/media3/transformer/AssetLoader` events.

## Summary

| ### Public methods |
|---|---|
| `abstract void` | `https://developer.android.com/reference/androidx/media3/transformer/AssetLoader.Listener#onDurationUs(long)(long durationUs)` Called when the duration of the input media is known. |
| `abstract void` | `https://developer.android.com/reference/androidx/media3/transformer/AssetLoader.Listener#onError(androidx.media3.transformer.ExportException)(https://developer.android.com/reference/androidx/media3/transformer/ExportException exportException)` Called if an error occurs in the asset loader. |
| `abstract @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/transformer/SampleConsumer` | `https://developer.android.com/reference/androidx/media3/transformer/AssetLoader.Listener#onOutputFormat(androidx.media3.common.Format)(https://developer.android.com/reference/androidx/media3/common/Format format)` Called when the `https://developer.android.com/reference/androidx/media3/common/Format` of samples that will be output by the `https://developer.android.com/reference/androidx/media3/transformer/AssetLoader` is known. |
| `abstract boolean` | `https://developer.android.com/reference/androidx/media3/transformer/AssetLoader.Listener#onTrackAdded(androidx.media3.common.Format,int)( https://developer.android.com/reference/androidx/media3/common/Format inputFormat, @https://developer.android.com/reference/androidx/media3/transformer/AssetLoader.SupportedOutputTypes int supportedOutputTypes )` Called when the information on a track is known. |
| `abstract void` | `https://developer.android.com/reference/androidx/media3/transformer/AssetLoader.Listener#onTrackCount(int)(@https://developer.android.com/reference/androidx/annotation/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 `https://developer.android.com/reference/androidx/media3/transformer/AssetLoader#release()` automatically.

Can be called from any thread.

### onOutputFormat

```
abstract @Nullable SampleConsumer onOutputFormat(Format format)
```

Called when the `https://developer.android.com/reference/androidx/media3/common/Format` of samples that will be output by the `https://developer.android.com/reference/androidx/media3/transformer/AssetLoader` is known.

Must be called after the corresponding track has been `https://developer.android.com/reference/androidx/media3/transformer/AssetLoader.Listener#onTrackAdded(androidx.media3.common.Format,int)`.

For each `https://developer.android.com/reference/androidx/media3/transformer/AssetLoader.Listener#onTrackAdded(androidx.media3.common.Format,int)` track, this method must be called regularly until the returned `https://developer.android.com/reference/androidx/media3/transformer/SampleConsumer` is non-null.

Must be called from the thread that will be used to call the returned `https://developer.android.com/reference/androidx/media3/transformer/SampleConsumer`'s methods. This thread must be the same for all formats output, and is generally different from the one used to access the `https://developer.android.com/reference/androidx/media3/transformer/AssetLoader` methods.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/Format format` | The `https://developer.android.com/reference/androidx/media3/common/Format` of samples that will be output. |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/transformer/SampleConsumer` | The `https://developer.android.com/reference/androidx/media3/transformer/SampleConsumer` of samples of the given `https://developer.android.com/reference/androidx/media3/common/Format`, or `null` if it could not be retrieved yet. |

| Throws |
|---|---|
| `https://developer.android.com/reference/androidx/media3/transformer/ExportException` | If an error occurs configuring the `https://developer.android.com/reference/androidx/media3/transformer/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 `https://developer.android.com/reference/androidx/media3/transformer/AssetLoader.Listener#onDurationUs(long)` and the `https://developer.android.com/reference/androidx/media3/transformer/AssetLoader.Listener#onTrackCount(int)` have been reported.

Must be called once per `https://developer.android.com/reference/androidx/media3/transformer/AssetLoader.Listener#onTrackCount(int)` track.

Must be called from the thread that will be used to call `https://developer.android.com/reference/androidx/media3/transformer/AssetLoader.Listener#onOutputFormat(androidx.media3.common.Format)`.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/Format inputFormat` | The `https://developer.android.com/reference/androidx/media3/common/Format` of samples that will be input to the `https://developer.android.com/reference/androidx/media3/transformer/AssetLoader` (prior to video slow motion flattening or to decoding). |
| `@https://developer.android.com/reference/androidx/media3/transformer/AssetLoader.SupportedOutputTypes int supportedOutputTypes` | The output `https://developer.android.com/reference/androidx/media3/transformer/AssetLoader.SupportedOutputTypes` supported by this `https://developer.android.com/reference/androidx/media3/transformer/AssetLoader` for the track added. At least one output type must be supported. |

| Returns |
|---|---|
| `boolean` | Whether the `https://developer.android.com/reference/androidx/media3/transformer/AssetLoader` needs to provide decoded data to the `https://developer.android.com/reference/androidx/media3/transformer/SampleConsumer`. |

### 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.