# SurfaceAssetLoader

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/SurfaceAssetLoader.java+class:androidx.media3.transformer.SurfaceAssetLoader)

*** ** * ** ***

<br />

```
@UnstableApi
public final class SurfaceAssetLoader implements AssetLoader
```

<br />

*** ** * ** ***

Asset loader that outputs video data passed to its input `https://developer.android.com/reference/android/view/Surface.html`.

To use this asset loader, pass a callback to the `https://developer.android.com/reference/androidx/media3/transformer/SurfaceAssetLoader.Factory` constructor to get access to the underlying asset loader and `https://developer.android.com/reference/android/view/Surface.html` to write to once they are ready. Then pass the factory to `https://developer.android.com/reference/androidx/media3/transformer/Transformer.Builder#setAssetLoaderFactory(androidx.media3.transformer.AssetLoader.Factory)`.

The media item passed to transformer must have a URI starting with the scheme `https://developer.android.com/reference/androidx/media3/transformer/SurfaceAssetLoader#MEDIA_ITEM_URI_SCHEME()`.

Call `https://developer.android.com/reference/androidx/media3/transformer/SurfaceAssetLoader#signalEndOfInput()` when the input stream ends, which will cause the transformation to complete.

## Summary

| ### Nested types |
|---|
| `public interface https://developer.android.com/reference/androidx/media3/transformer/SurfaceAssetLoader.Callback` Callbacks for `https://developer.android.com/reference/androidx/media3/transformer/SurfaceAssetLoader` events. |
| `public final class https://developer.android.com/reference/androidx/media3/transformer/SurfaceAssetLoader.Factory implements https://developer.android.com/reference/androidx/media3/transformer/AssetLoader.Factory` Factory for `https://developer.android.com/reference/androidx/media3/transformer/SurfaceAssetLoader` instances. |

| ### Constants |
|---|---|
| `static final https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/media3/transformer/SurfaceAssetLoader#MEDIA_ITEM_URI_SCHEME() = "transformer_surface_asset"` URI scheme for creating a `https://developer.android.com/reference/androidx/media3/common/MediaItem` that signals that the media is provided from this asset loader. |

| ### Public fields |
|---|---|
| `final https://developer.android.com/reference/androidx/media3/transformer/EditedMediaItem` | `https://developer.android.com/reference/androidx/media3/transformer/SurfaceAssetLoader#editedMediaItem()` |

| ### Public methods |
|---|---|
| `https://guava.dev/releases/snapshot-android/api/docs/com/google/common/collect/ImmutableMap.html<https://developer.android.com/reference/java/lang/Integer.html, https://developer.android.com/reference/java/lang/String.html>` | `https://developer.android.com/reference/androidx/media3/transformer/SurfaceAssetLoader#getDecoderNames()()` Return the used decoders' names. |
| `https://developer.android.com/reference/androidx/media3/transformer/EditedMediaItem` | `https://developer.android.com/reference/androidx/media3/transformer/SurfaceAssetLoader#getEditedMediaItem()()` Returns the `https://developer.android.com/reference/androidx/media3/transformer/EditedMediaItem` being loaded by this instance. |
| `int` | `@https://developer.android.com/reference/androidx/media3/transformer/Transformer.ProgressState https://developer.android.com/reference/androidx/media3/transformer/SurfaceAssetLoader#getProgress(androidx.media3.transformer.ProgressHolder)(https://developer.android.com/reference/androidx/media3/transformer/ProgressHolder progressHolder)` Returns the current `https://developer.android.com/reference/androidx/media3/transformer/Transformer.ProgressState` and updates `progressHolder` with the current progress if it is `https://developer.android.com/reference/androidx/media3/transformer/Transformer#PROGRESS_STATE_AVAILABLE()`. |
| `void` | `https://developer.android.com/reference/androidx/media3/transformer/SurfaceAssetLoader#release()()` Stops loading data and releases all resources associated with the asset loader. |
| `void` | `https://developer.android.com/reference/androidx/media3/transformer/SurfaceAssetLoader#setContentFormat(androidx.media3.common.Format)(https://developer.android.com/reference/androidx/media3/common/Format contentFormat)` Sets the video content format, which must have a raw video sample MIME type, width, height and color info. |
| `void` | `https://developer.android.com/reference/androidx/media3/transformer/SurfaceAssetLoader#signalEndOfInput()()` Signals that no further input frames will be rendered. |
| `void` | `https://developer.android.com/reference/androidx/media3/transformer/SurfaceAssetLoader#start()()` Starts the asset loader. |

### Inherited Constants

From [androidx.media3.transformer.AssetLoader](https://developer.android.com/reference/androidx/media3/transformer/AssetLoader) `static final int` `https://developer.android.com/reference/androidx/media3/transformer/AssetLoader#SUPPORTED_OUTPUT_TYPE_DECODED() = 2`

Indicates that the asset loader can output decoded samples.
`static final int` `https://developer.android.com/reference/androidx/media3/transformer/AssetLoader#SUPPORTED_OUTPUT_TYPE_ENCODED() = 1`

Indicates that the asset loader can output encoded samples.

## Constants

### MEDIA_ITEM_URI_SCHEME

```
public static final String MEDIA_ITEM_URI_SCHEME = "transformer_surface_asset"
```

URI scheme for creating a `https://developer.android.com/reference/androidx/media3/common/MediaItem` that signals that the media is provided from this asset loader.

## Public fields

### editedMediaItem

```
public final EditedMediaItem editedMediaItem
```

## Public methods

### getDecoderNames

```
public ImmutableMap<Integer, String> getDecoderNames()
```

Return the used decoders' names.

| Returns |
|---|---|
| `https://guava.dev/releases/snapshot-android/api/docs/com/google/common/collect/ImmutableMap.html<https://developer.android.com/reference/java/lang/Integer.html, https://developer.android.com/reference/java/lang/String.html>` | The decoders' names keyed by `https://developer.android.com/reference/androidx/media3/common/C.TrackType`. |

### getEditedMediaItem

```
public EditedMediaItem getEditedMediaItem()
```

Returns the `https://developer.android.com/reference/androidx/media3/transformer/EditedMediaItem` being loaded by this instance.

### getProgress

```
@Transformer.ProgressState
public int getProgress(ProgressHolder progressHolder)
```

Returns the current `https://developer.android.com/reference/androidx/media3/transformer/Transformer.ProgressState` and updates `progressHolder` with the current progress if it is `https://developer.android.com/reference/androidx/media3/transformer/Transformer#PROGRESS_STATE_AVAILABLE()`.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/transformer/ProgressHolder progressHolder` | A `https://developer.android.com/reference/androidx/media3/transformer/ProgressHolder`, updated to hold the percentage progress if `https://developer.android.com/reference/androidx/media3/transformer/Transformer#PROGRESS_STATE_AVAILABLE()`. |

| Returns |
|---|---|
| `int` | The `https://developer.android.com/reference/androidx/media3/transformer/Transformer.ProgressState`. |

### release

```
public void release()
```

Stops loading data and releases all resources associated with the asset loader.

### setContentFormat

```
public void setContentFormat(Format contentFormat)
```

Sets the video content format, which must have a raw video sample MIME type, width, height and color info. May be called on any thread.

### signalEndOfInput

```
public void signalEndOfInput()
```

Signals that no further input frames will be rendered. May be called on any thread.

### start

```
public void start()
```

Starts the asset loader.