SurfaceAssetLoader


@UnstableApi
class SurfaceAssetLoader : AssetLoader


Asset loader that outputs video data passed to its input Surface.

To use this asset loader, pass a callback to the factory's constructor to get access to the underlying asset loader and Surface to write to once they are ready. Then pass the factory to setAssetLoaderFactory.

The media item passed to transformer must have a URI starting with the scheme MEDIA_ITEM_URI_SCHEME.

Call signalEndOfInput when the input stream ends, which will cause the transformation to complete.

Summary

Nested types

Callbacks for SurfaceAssetLoader events.

Factory for SurfaceAssetLoader instances.

Constants

const String!
MEDIA_ITEM_URI_SCHEME = "transformer_surface_asset"

URI scheme for creating a MediaItem that signals that the media is provided from this asset loader.

Public functions

ImmutableMap<Int!, String!>!

Return the used decoders' names.

Int

Returns the current Transformer.ProgressState and updates progressHolder with the current progress if it is available.

Unit

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

Unit
setContentFormat(contentFormat: Format!)

Sets the video content format, which must have a raw video sample MIME type, width, height and color info.

Unit

Signals that no further input frames will be rendered.

Unit

Starts the asset loader.

Public properties

EditedMediaItem!

Inherited Constants

From androidx.media3.transformer.AssetLoader
const Int

Indicates that the asset loader can output decoded samples.

const Int

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 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
ImmutableMap<Int!, String!>!

The decoders' names keyed by track type.

getProgress

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

Returns the current Transformer.ProgressState and updates progressHolder with the current progress if it is available.

Parameters
progressHolder: ProgressHolder!

A ProgressHolder, updated to hold the percentage progress if available.

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 editedMediaItemEditedMediaItem!