LottieOverlay


@UnstableApi
class LottieOverlay : 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

A builder for LottieOverlay instances.

Provides assets for a Lottie animation and manages their lifecycle.

Public functions

Unit
configure(videoSize: Size!)

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

OverlaySettings!
getOverlaySettings(presentationTimeUs: Long)

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

synchronized Unit
onDraw(canvas: Canvas!, presentationTimeUs: Long)

Perform custom drawing onto the Canvas.

synchronized Unit

Releases all resources.

Inherited functions

From androidx.media3.effect.BitmapOverlay
java-static BitmapOverlay!

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

java-static BitmapOverlay!
createStaticBitmapOverlay(
    overlayBitmap: Bitmap!,
    overlaySettings: StaticOverlaySettings!
)

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

java-static BitmapOverlay!
createStaticBitmapOverlay(
    context: Context!,
    overlayBitmapUri: Uri!,
    overlaySettings: StaticOverlaySettings!
)

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

Int
getTextureId(presentationTimeUs: Long)

Returns the overlay texture identifier displayed at the specified timestamp.

Size!
getTextureSize(presentationTimeUs: Long)

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

FloatArray<Float>!
getVertexTransformation(presentationTimeUs: Long)

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(presentationTimeUs: Long)

Returns the overlay bitmap displayed at the specified timestamp.

Unit
setCanvasSize(width: Int, height: Int)

Sets the size of the Canvas.

Public functions

configure

fun configure(videoSize: Size!): Unit

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
videoSize: Size!

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

getOverlaySettings

fun getOverlaySettings(presentationTimeUs: Long): OverlaySettings!

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

Parameters
presentationTimeUs: Long

The presentation timestamp of the current frame, in microseconds.

onDraw

synchronized fun onDraw(canvas: Canvas!, presentationTimeUs: Long): Unit

Perform custom drawing onto the Canvas.

Parameters
canvas: Canvas!

The Canvas to draw onto.

presentationTimeUs: Long

The presentation timestamp, in microseconds.

release

synchronized fun release(): Unit

Releases all resources.

Throws
androidx.media3.common.VideoFrameProcessingException

If an error occurs while releasing resources.