[Feature Request] Make SubtitlePainter public to facilitate custom subtitle rendering (e.g., on SurfaceTexture/Canvas)
Nobody has claimed this yet.
- 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
- Copy-pasting code: Currently, I have to copy the entire
SubtitlePainterclass (and some internal dependencies/resources) into my project to replicate the rendering logic. This is brittle and hard to maintain as the library updates. - Implementing from scratch: Re-implementing the logic to parse
Cuepositioning, text size, and styling attributes to draw them correctly on aCanvasis 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.