androidx / androidx/media

[Feature Request] Make SubtitlePainter public to facilitate custom subtitle rendering (e.g., on SurfaceTexture/Canvas)

Open
#3,001 1 comment 0 reactions 1 assignee View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Java
Stars
3k
Forks
955
Avg merge
12d 14h
Merged PRs (30d)
2

Description

[REQUIRED] Use case description

Currently, the SubtitlePainter class (located in androidx.media3.ui) is package-private.
While SubtitleView works great for standard Android View layouts, it is impossible to use when the rendering target is not a standard UI component. A common use case is rendering video to a SurfaceTexture, TextureView, or directly within an OpenGL context (e.g., VR applications, video editing/compositing, or custom rendering pipelines).
In these scenarios, developers need to draw Cue directly onto a Canvas backed by a Bitmap or Surface, without attaching a View to the hierarchy. SubtitlePainter already encapsulates the complex logic of positioning, styling, and drawing cues onto a Canvas, but it is inaccessible.

Proposed solution

I would like to request that SubtitlePainter be made public.
Exposing this class would allow developers to instantiate it and use its draw(...) method to render subtitles onto any arbitrary Canvas.

Alternatives considered
  1. Copy-pasting code: Currently, I have to copy the entire SubtitlePainter class (and some internal dependencies/resources) into my project to replicate the rendering logic. This is brittle and hard to maintain as the library updates.
  2. Implementing from scratch: Re-implementing the logic to parse Cue positioning, text size, and styling attributes to draw them correctly on a Canvas is error-prone and redundant since the logic already exists in the library.

Making this class public would greatly improve the flexibility of the library for advanced rendering use cases.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.