-
Notifications
You must be signed in to change notification settings - Fork 629
Add Compose-based (Material 3) SubtitleView for rendering CueGroup in Jetpack Compose #2838
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
… in dp across devices with different DPIs (e.g., phones at 320 dpi, TVs at 240 dpi), ensuring PSG subtitles are correctly positioned.
Hi @mzhsy1, Thank you for your contribution. I appreciate you taking the time to create this composable. However, this pull request does not meet the standards required for merging into the library in its current state. Things like:
From the design perspective, we are unsure for now about going ahead with using Image() composables. In the View world, https://github.com/androidx/media/blob/release/libraries/ui/src/main/java/androidx/media3/ui/SubtitleView.java delegated to https://github.com/androidx/media/blob/release/libraries/ui/src/main/java/androidx/media3/ui/CanvasSubtitleOutput.java and https://github.com/androidx/media/blob/release/libraries/ui/src/main/java/androidx/media3/ui/WebViewSubtitleOutput.java. You can see how thorough and detailed those cases are and we would want to match that. Perhaps with using Canvas ( I suggest we park this PR until next quarter and revisit it next quarter when we will have more resources to dedicate to it. |
Thank you for your reply. This Compose component is part of my personal project, created to replace the SubtitleView in PlayerView. The built-in SubtitleView has two issues that don’t meet my needs: first, it displays PGS subtitles from certain Blu-ray disc rips with incorrect aspect ratios; second, when multiple SRT subtitle entries share the same timestamp, it only shows one of them. This Compose component successfully addresses both issues and is currently working well in my project. However, it may fail to fully render PGS subtitles when too many images appear on screen simultaneously. I’ve seen your suggestion to switch from Modifier.offset(x = offsetX.dp - 14.dp, y = offsetY.dp - 8.dp) This offset is used to correct the display position of PGS subtitles. At the moment, I’m not sure why these specific offset values are necessary during normal rendering—it just happens to fix the misalignment. I’m currently experimenting in my personal project with migrating both Thank you for your suggestion! For now, I won’t submit these changes to this PR. If you develop a better subtitle rendering solution, please release it as soon as possible—I’ll prioritize adopting it. |
Bit of a drive-by:
This sounds possibly similar to #2446 - which I think was resolved by ensuring the If it's not the same, please can you file a new issue with content we can use to repro the issue in the demo app and we can take a look. |
It seems that issue #2446 has not been resolved. |
|
Summary
This PR introduces a new Jetpack Compose composable,
SubtitleView
, designed to render subtitles provided by Media3'sCueGroup
. It supports both text cues (e.g., SRT, SSA/ASS converted by ExoPlayer) and bitmap cues (e.g., PNG images), respecting their layout properties such as position, size, and anchor point.The component is built using Material 3 guidelines and provides customizable styling for text subtitles, including text style and background color. It is intended for use within Compose-based media player UIs.
Features
CueGroup
.TextStyle
and background for text cues.Example Usage
Test
SRT Rendering
PGS Rendering