CanvasOverlay
@UnstableApi
public abstract class CanvasOverlay extends BitmapOverlay
| java.lang.Object | |||
| ↳ | 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(boolean useInputFrameSize)Creates a new |
Public methods |
|
|---|---|
void |
Set up resources for the overlay given the input video’s dimensions. |
Bitmap |
getBitmap(long presentationTimeUs)Returns the overlay bitmap displayed at the specified timestamp. |
abstract void |
Perform custom drawing onto the |
void |
release()Releases all resources. |
void |
setCanvasSize(int width, int height)Sets the size of the |
Inherited methods |
||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
||||||||||||
|
Public constructors
CanvasOverlay
public CanvasOverlay(boolean useInputFrameSize)
Creates a new CanvasOverlay.
| Parameters | |
|---|---|
boolean useInputFrameSize |
Whether to create the |
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. |
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. |
onDraw
public abstract void onDraw(Canvas canvas, long presentationTimeUs)
Perform custom drawing onto the Canvas.
release
public void release()
Releases all resources.
| Throws | |
|---|---|
androidx.media3.common.VideoFrameProcessingException |
If an error occurs while releasing resources. |
setCanvasSize
public void setCanvasSize(int width, int height)
Sets the size of the Canvas.
The default canvas size will be of the same size as the video frame.
The size will be applied on the next invocation of onDraw.