CanvasOverlay
@UnstableApi
abstract class CanvasOverlay : BitmapOverlay
| kotlin.Any | |||
| ↳ | androidx.media3.effect.TextureOverlay | ||
| ↳ | androidx.media3.effect.BitmapOverlay | ||
| ↳ | androidx.media3.effect.CanvasOverlay |
LottieOverlay |
A |
A TextOverlay that is backed by a Canvas.
Use this class when the size of the drawing Canvas is known, or when drawing to the entire video size is desied.
Summary
Public constructors |
|---|
CanvasOverlay(useInputFrameSize: Boolean)Creates a new |
Public functions |
|
|---|---|
Unit |
Set up resources for the overlay given the input video’s dimensions. |
Bitmap! |
Returns the overlay bitmap displayed at the specified timestamp. |
abstract Unit |
Perform custom drawing onto the |
Unit |
release()Releases all resources. |
Unit |
setCanvasSize(width: Int, height: Int)Sets the size of the |
Inherited functions |
||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
||||||||||||
|
Public constructors
CanvasOverlay
CanvasOverlay(useInputFrameSize: Boolean)
Creates a new CanvasOverlay.
| Parameters | |
|---|---|
useInputFrameSize: Boolean |
Whether to create the |
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. |
getBitmap
fun getBitmap(presentationTimeUs: Long): Bitmap!
Returns the overlay bitmap displayed at the specified timestamp.
| Parameters | |
|---|---|
presentationTimeUs: Long |
The presentation timestamp of the current frame, in microseconds. |
| Throws | |
|---|---|
androidx.media3.common.VideoFrameProcessingException |
If an error occurs while processing or drawing the frame. |
onDraw
abstract fun onDraw(canvas: Canvas!, presentationTimeUs: Long): Unit
Perform custom drawing onto the Canvas.
release
fun release(): Unit
Releases all resources.
| Throws | |
|---|---|
androidx.media3.common.VideoFrameProcessingException |
If an error occurs while releasing resources. |