@UnstableApi
public abstract class TextOverlay extends BitmapOverlay


Creates a TextureOverlay from text.

Uses a SpannableString to store the text and support advanced per-character text styling.

Summary

Constants

static final int

Public constructors

Public methods

static TextOverlay

Creates a TextOverlay that shows the overlayText with the same default settings in OverlaySettings throughout the whole video.

static TextOverlay
createStaticTextOverlay(
    SpannableString overlayText,
    OverlaySettings overlaySettings
)

Creates a TextOverlay that shows the overlayText with the same throughout the whole video.

Bitmap
getBitmap(long presentationTimeUs)

Returns the overlay bitmap displayed at the specified timestamp.

abstract SpannableString
getText(long presentationTimeUs)

Returns the overlay text displayed at the specified timestamp.

Inherited methods

From androidx.media3.effect.BitmapOverlay
static BitmapOverlay

Creates a BitmapOverlay that shows the overlayBitmap in the same position and size throughout the whole video.

static BitmapOverlay
createStaticBitmapOverlay(
    Bitmap overlayBitmap,
    OverlaySettings overlaySettings
)

Creates a BitmapOverlay that shows the overlayBitmap in the same throughout the whole video.

static BitmapOverlay
createStaticBitmapOverlay(
    Context context,
    Uri overlayBitmapUri,
    OverlaySettings overlaySettings
)

Creates a BitmapOverlay that shows the input at overlayBitmapUri with the same OverlaySettings throughout the whole video.

int
getTextureId(long presentationTimeUs)

Returns the overlay texture identifier displayed at the specified timestamp.

Size
getTextureSize(long presentationTimeUs)

Returns the pixel width and height of the overlay texture displayed at the specified timestamp.

float[]
getVertexTransformation(long presentationTimeUs)

Returns a 4x4 OpenGL matrix, controlling how the vertices of the overlay are displayed at the specified timestamp.

void

Releases all resources.

From androidx.media3.effect.TextureOverlay
void
configure(Size videoSize)

Set up resources for the overlay given the input video’s dimensions.

OverlaySettings
getOverlaySettings(long presentationTimeUs)

Returns the OverlaySettings controlling how the overlay is displayed at the specified timestamp.

Constants

TEXT_SIZE_PIXELS

public static final int TEXT_SIZE_PIXELS = 100

Public constructors

TextOverlay

public TextOverlay()

Public methods

createStaticTextOverlay

public static TextOverlay createStaticTextOverlay(SpannableString overlayText)

Creates a TextOverlay that shows the overlayText with the same default settings in OverlaySettings throughout the whole video.

createStaticTextOverlay

public static TextOverlay createStaticTextOverlay(
    SpannableString overlayText,
    OverlaySettings overlaySettings
)

Creates a TextOverlay that shows the overlayText with the same throughout the whole video.

Parameters
SpannableString overlayText

The text to overlay on the video.

OverlaySettings overlaySettings

The OverlaySettings configuring how the overlay is displayed on the frames.

getBitmap

public Bitmap getBitmap(long presentationTimeUs)

Returns the overlay bitmap displayed at the specified timestamp.

Parameters
long presentationTimeUs

The presentation timestamp of the current frame, in microseconds.

Throws
androidx.media3.common.VideoFrameProcessingException

If an error occurs while processing or drawing the frame.

getText

public abstract SpannableString getText(long presentationTimeUs)

Returns the overlay text displayed at the specified timestamp.

Parameters
long presentationTimeUs

The presentation timestamp of the current frame, in microseconds.