LottieOverlay


@UnstableApi
public final class LottieOverlay extends CanvasOverlay


A CanvasOverlay that renders a Lottie animation.

This overlay uses the Lottie library to draw an animation loaded from a raw resource. The animation's size, position, speed, and looping behavior can be configured using the Builder.

Summary

Nested types

public final class LottieOverlay.Builder

A builder for LottieOverlay instances.

Provides assets for a Lottie animation and manages their lifecycle.

Public methods

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.

synchronized void
onDraw(Canvas canvas, long presentationTimeUs)

Perform custom drawing onto the Canvas.

synchronized void

Releases all resources.

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,
    StaticOverlaySettings overlaySettings
)

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

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

Creates a BitmapOverlay that shows the input at overlayBitmapUri with the same StaticOverlaySettings 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.

From androidx.media3.effect.CanvasOverlay
Bitmap
getBitmap(long presentationTimeUs)

Returns the overlay bitmap displayed at the specified timestamp.

void
setCanvasSize(int width, int height)

Sets the size of the Canvas.

Public methods

configure

public void configure(Size videoSize)

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

This method will be called before drawing the first frame and before drawing subsequent frames with different input dimensions.

Parameters
Size videoSize

The width and height of the input video, in pixels.

getOverlaySettings

public OverlaySettings getOverlaySettings(long presentationTimeUs)

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

Parameters
long presentationTimeUs

The presentation timestamp of the current frame, in microseconds.

onDraw

synchronized public void onDraw(Canvas canvas, long presentationTimeUs)

Perform custom drawing onto the Canvas.

Parameters
Canvas canvas

The Canvas to draw onto.

long presentationTimeUs

The presentation timestamp, in microseconds.

release

synchronized public void release()

Releases all resources.

Throws
androidx.media3.common.VideoFrameProcessingException

If an error occurs while releasing resources.