# 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
class SurfaceAssetLoader : 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/kotlin/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/kotlin/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/kotlin/androidx/media3/transformer/SurfaceAssetLoader#MEDIA_ITEM_URI_SCHEME()`.

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

## Summary

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

| ### Constants |
|---|---|
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | `https://developer.android.com/reference/kotlin/androidx/media3/transformer/SurfaceAssetLoader#MEDIA_ITEM_URI_SCHEME() = "transformer_surface_asset"` URI scheme for creating a `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem` that signals that the media is provided from this asset loader. |

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

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

### Inherited Constants

From [androidx.media3.transformer.AssetLoader](https://developer.android.com/reference/kotlin/androidx/media3/transformer/AssetLoader) `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` `https://developer.android.com/reference/kotlin/androidx/media3/transformer/AssetLoader#SUPPORTED_OUTPUT_TYPE_DECODED() = 2`

Indicates that the asset loader can output decoded samples.
`const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` `https://developer.android.com/reference/kotlin/androidx/media3/transformer/AssetLoader#SUPPORTED_OUTPUT_TYPE_ENCODED() = 1`

Indicates that the asset loader can output encoded samples.

## Constants

### MEDIA_ITEM_URI_SCHEME

```
const val MEDIA_ITEM_URI_SCHEME = "transformer_surface_asset": String!
```

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

## Public functions

### getDecoderNames

```
fun getDecoderNames(): ImmutableMap<Int!, String!>!
```

Return the used decoders' names.

| Returns |
|---|---|
| `https://guava.dev/releases/snapshot-android/api/docs/com/google/common/collect/ImmutableMap.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html!, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!>!` | The decoders' names keyed by `https://developer.android.com/reference/kotlin/androidx/media3/common/C.TrackType`. |

### getProgress

```
@Transformer.ProgressState
fun getProgress(progressHolder: ProgressHolder!): Int
```

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

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

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The `https://developer.android.com/reference/kotlin/androidx/media3/transformer/Transformer.ProgressState`. |

### release

```
fun release(): Unit
```

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

### setContentFormat

```
fun setContentFormat(contentFormat: Format!): Unit
```

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

```
fun signalEndOfInput(): Unit
```

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

### start

```
fun start(): Unit
```

Starts the asset loader.

## Public properties

### editedMediaItem

```
val editedMediaItem: EditedMediaItem!
```