# TextOverlay

Artifact: [androidx.media3:media3-effect](https://developer.android.com/jetpack/androidx/releases/media3) [View Source](https://cs.android.com/search?q=file:androidx/media3/effect/TextOverlay.java+class:androidx.media3.effect.TextOverlay)

*** ** * ** ***


```
@UnstableApi
public abstract class TextOverlay extends BitmapOverlay
```

<br />

|---|---|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object.html) ||||
| ↳ | [androidx.media3.effect.TextureOverlay](https://developer.android.com/reference/androidx/media3/effect/TextureOverlay) |||
|   | ↳ | [androidx.media3.effect.BitmapOverlay](https://developer.android.com/reference/androidx/media3/effect/BitmapOverlay) ||
|   |   | ↳ | [androidx.media3.effect.TextOverlay](https://developer.android.com/reference/androidx/media3/effect/TextOverlay) |

*** ** * ** ***

Creates a `https://developer.android.com/reference/androidx/media3/effect/TextureOverlay` from text.

Uses a `https://developer.android.com/reference/android/text/SpannableString.html` to store the text and support advanced per-character text styling.

## Summary

| ### Constants |
|---|---|
| `static final int` | `https://developer.android.com/reference/androidx/media3/effect/TextOverlay#TEXT_SIZE_PIXELS() = 100` |

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/media3/effect/TextOverlay#TextOverlay()()` |

| ### Public methods |
|---|---|
| `static https://developer.android.com/reference/androidx/media3/effect/TextOverlay` | `https://developer.android.com/reference/androidx/media3/effect/TextOverlay#createStaticTextOverlay(android.text.SpannableString)(https://developer.android.com/reference/android/text/SpannableString.html overlayText)` Creates a `https://developer.android.com/reference/androidx/media3/effect/TextOverlay` that shows the `overlayText` with the same default settings in `https://developer.android.com/reference/androidx/media3/effect/StaticOverlaySettings` throughout the whole video. |
| `static https://developer.android.com/reference/androidx/media3/effect/TextOverlay` | `https://developer.android.com/reference/androidx/media3/effect/TextOverlay#createStaticTextOverlay(android.text.SpannableString,androidx.media3.effect.StaticOverlaySettings)( https://developer.android.com/reference/android/text/SpannableString.html overlayText, https://developer.android.com/reference/androidx/media3/effect/StaticOverlaySettings overlaySettings )` Creates a `https://developer.android.com/reference/androidx/media3/effect/TextOverlay` that shows the `overlayText` with the same `https://developer.android.com/reference/androidx/media3/effect/StaticOverlaySettings` throughout the whole video. |
| `https://developer.android.com/reference/android/graphics/Bitmap.html` | `https://developer.android.com/reference/androidx/media3/effect/TextOverlay#getBitmap(long)(long presentationTimeUs)` Returns the overlay bitmap displayed at the specified timestamp. |
| `abstract https://developer.android.com/reference/android/text/SpannableString.html` | `https://developer.android.com/reference/androidx/media3/effect/TextOverlay#getText(long)(long presentationTimeUs)` Returns the overlay text displayed at the specified timestamp. |

| ### Inherited methods |
|---|
| From [androidx.media3.effect.BitmapOverlay](https://developer.android.com/reference/androidx/media3/effect/BitmapOverlay) |---|---| | `static https://developer.android.com/reference/androidx/media3/effect/BitmapOverlay` | `https://developer.android.com/reference/androidx/media3/effect/BitmapOverlay#createStaticBitmapOverlay(android.graphics.Bitmap)(https://developer.android.com/reference/android/graphics/Bitmap.html overlayBitmap)` Creates a `https://developer.android.com/reference/androidx/media3/effect/BitmapOverlay` that shows the `overlayBitmap` in the same position and size throughout the whole video. | | `static https://developer.android.com/reference/androidx/media3/effect/BitmapOverlay` | `https://developer.android.com/reference/androidx/media3/effect/BitmapOverlay#createStaticBitmapOverlay(android.graphics.Bitmap,androidx.media3.effect.StaticOverlaySettings)( https://developer.android.com/reference/android/graphics/Bitmap.html overlayBitmap, https://developer.android.com/reference/androidx/media3/effect/StaticOverlaySettings overlaySettings )` Creates a `https://developer.android.com/reference/androidx/media3/effect/BitmapOverlay` that shows the `overlayBitmap` in the same `https://developer.android.com/reference/androidx/media3/common/OverlaySettings` throughout the whole video. | | `static https://developer.android.com/reference/androidx/media3/effect/BitmapOverlay` | `https://developer.android.com/reference/androidx/media3/effect/BitmapOverlay#createStaticBitmapOverlay(android.content.Context,android.net.Uri,androidx.media3.effect.StaticOverlaySettings)( https://developer.android.com/reference/android/content/Context.html context, https://developer.android.com/reference/android/net/Uri.html overlayBitmapUri, https://developer.android.com/reference/androidx/media3/effect/StaticOverlaySettings overlaySettings )` Creates a `https://developer.android.com/reference/androidx/media3/effect/BitmapOverlay` that shows the input at `overlayBitmapUri` with the same `https://developer.android.com/reference/androidx/media3/effect/StaticOverlaySettings` throughout the whole video. | | `int` | `https://developer.android.com/reference/androidx/media3/effect/BitmapOverlay#getTextureId(long)(long presentationTimeUs)` Returns the overlay texture identifier displayed at the specified timestamp. | | `https://developer.android.com/reference/androidx/media3/common/util/Size` | `https://developer.android.com/reference/androidx/media3/effect/BitmapOverlay#getTextureSize(long)(long presentationTimeUs)` Returns the pixel width and height of the overlay texture displayed at the specified timestamp. | | `float[]` | `https://developer.android.com/reference/androidx/media3/effect/BitmapOverlay#getVertexTransformation(long)(long presentationTimeUs)` Returns a 4x4 OpenGL matrix, controlling how the vertices of the overlay are displayed at the specified timestamp. | | `void` | `https://developer.android.com/reference/androidx/media3/effect/BitmapOverlay#release()()` Releases all resources. | |
| From [androidx.media3.effect.TextureOverlay](https://developer.android.com/reference/androidx/media3/effect/TextureOverlay) |---|---| | `void` | `https://developer.android.com/reference/androidx/media3/effect/TextureOverlay#configure(androidx.media3.common.util.Size)(https://developer.android.com/reference/androidx/media3/common/util/Size videoSize)` Set up resources for the overlay given the input video's dimensions. | | `https://developer.android.com/reference/androidx/media3/common/OverlaySettings` | `https://developer.android.com/reference/androidx/media3/effect/TextureOverlay#getOverlaySettings(long)(long presentationTimeUs)` Returns the `https://developer.android.com/reference/androidx/media3/common/OverlaySettings` controlling how the overlay is displayed at the specified timestamp. | |

## Constants

### TEXT_SIZE_PIXELS

```
public static final int TEXT_SIZE_PIXELS = 100
```

## Public constructors

### TextOverlay

```
public TextOverlay()
```

## Public methods

### createStaticTextOverlay

```
public static TextOverlay createStaticTextOverlay(SpannableString overlayText)
```

Creates a `https://developer.android.com/reference/androidx/media3/effect/TextOverlay` that shows the `overlayText` with the same default settings in `https://developer.android.com/reference/androidx/media3/effect/StaticOverlaySettings` throughout the whole video.

### createStaticTextOverlay

```
public static TextOverlay createStaticTextOverlay(
    SpannableString overlayText,
    StaticOverlaySettings overlaySettings
)
```

Creates a `https://developer.android.com/reference/androidx/media3/effect/TextOverlay` that shows the `overlayText` with the same `https://developer.android.com/reference/androidx/media3/effect/StaticOverlaySettings` throughout the whole video.

| Parameters |
|---|---|
| `https://developer.android.com/reference/android/text/SpannableString.html overlayText` | The text to overlay on the video. |
| `https://developer.android.com/reference/androidx/media3/effect/StaticOverlaySettings overlaySettings` | The `https://developer.android.com/reference/androidx/media3/effect/StaticOverlaySettings` 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 |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/VideoFrameProcessingException` | If an error occurs while processing or drawing the frame. |

### getText

```
public abstract SpannableString getText(long presentationTimeUs)
```

Returns the overlay text displayed at the specified timestamp.

| Parameters |
|---|---|
| `long presentationTimeUs` | The presentation timestamp of the current frame, in microseconds. |