DrawableOverlay


@UnstableApi
public abstract class DrawableOverlay extends BitmapOverlay


Creates a TextureOverlay from Drawable.

Uses a canvas to draw DrawableOverlay onto BitmapOverlay, which is then displayed on each frame.

Summary

Public constructors

Public methods

static DrawableOverlay
createStaticDrawableOverlay(
    Drawable drawable,
    OverlaySettings overlaySettings
)

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

Bitmap
getBitmap(long presentationTimeUs)

Returns the overlay bitmap displayed at the specified timestamp.

abstract Drawable
getDrawable(long presentationTimeUs)

Returns the overlay Drawable 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.

Public constructors

DrawableOverlay

public DrawableOverlay()

Public methods

createStaticDrawableOverlay

public static DrawableOverlay createStaticDrawableOverlay(
    Drawable drawable,
    OverlaySettings overlaySettings
)

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

Parameters
Drawable drawable

The Drawable to be displayed.

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.

getDrawable

public abstract Drawable getDrawable(long presentationTimeUs)

Returns the overlay Drawable displayed at the specified timestamp.

The drawable must have its bounds set via setBounds for drawable to be displayed on the frame.

Parameters
long presentationTimeUs

The presentation timestamp of the current frame, in microseconds.