Change External Subtitle Position on Exoplayer
See original GitHub issue[REQUIRED] Searched documentation and issues
Checked Subtitle view: https://exoplayer.dev/doc/reference/com/google/android/exoplayer2/ui/SubtitleView.html
[REQUIRED] Question
I want to change the subtitle position so for that i am using the following apis on Exoplayerview,
exoPlayerSubtitleView.setBottomPaddingFraction(); exoPlayerSubtitleView.setPadding();
Set padding is on View class and i am using that api.
My question is that is it the correct approach to move the position of subtitleview anywhere on the player screen because setBottomPaddingFraction helps me to move up and padding right and left gives me possibility to move right and left; I am keeping top and bottom as Zero values.
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (3 by maintainers)
Top Results From Across the Web
How to change ExoPlayer subtitle position in android?
I'm show subtitle with exoPlayer in my android application. Now I want change position of subtitle from bottom of the screen to the...
Read more >Exoplayer Subtitles - Top of Screen : r/SynclerApp - Reddit
Anyone have an issue where subtitles have moved to the top of Exoplayer, Can't find a way to move it to bottom, using...
Read more >Android Question change position subtitle in exoplayer - B4X
i'm try to change the position subtitle in exoplayer. search and find setBottomPaddingFraction in exoplayer. how can to use this void?
Read more >ExoPlayer in Android with Example - GeeksforGeeks
ExoPlayer is a media player library that provides a way to play audio and video with lots of customization in it. It is...
Read more >RELEASENOTES.md - google/ExoPlayer - Sourcegraph
Ensure that changing the ShuffleOrder with ExoPlayer. ... to true so that errors loading external subtitle files do not cause playback to fail...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Most subtitle formats can specify for each cue where in the viewport it should be drawn. The SubtitleView is transparent and exactly overlaid on the video viewport. The SubtitleView can position the cue text (or image) anywhere within itself, as specified by the positioning information from the subtitle source data.
In some cases, the position isn’t specified in the source data . This is usually indicated by
Cue.DIMEN_UNSETvalues forCue.lineand/orCue.position. In that case SubtitleView decides to draw the cue in a ‘default’ position, which is bottom-center. TheSubtitleView#setBottomPaddingFraction()method can change the vertical position of these cues (and specifically only the cues with no explicit positioning info from the source data). There’s currently no way to configure the horizontal position of this ‘default’.Do you want to position all cues in a fixed location, or only those that don’t carry their own positioning info?
You can achieve either by subclassing
PlayerViewand mutating the Cue objects inonCues()before passing them tosuper.onCues(). You’ll want to change thelineandpositionfields (and possiblylineAnchor,lineTypeandpositionAnchortoo). If you only want to move ‘default positioned’ cues, then only change a field if it’s set toCue.DIMEN_UNSET.Thanks for the sample project - I think I know what’s going on.
The subtitles in the stream you provided are WebVTT and don’t explicitly set the
sizeproperty (i.e. width for horizontal text). The WebVTT spec tells us to default tosize=100%in this case (step 3 here: https://www.w3.org/TR/webvtt1/#processing-cue-settings).Additionally the cues all have
alignment=middle(i.e. centre the text inside the cue box).So since you pass the Cue size straight through without modifying it, the cue box will always be spanning all the way to the right hand edge of the screen (because as you adjust
positionandpositionAnchor, thesizewill be shrunk just enough to avoid going out-of-bounds (i.e. > 100%)).And then since you also pass
alignmentstraight through, you’re only able to position cues in the middle of a box that spans all the way to the right hand edge of the screen. This makes it impossible to ever get cues into the left hand portion of the screen.You should be able to fix this by modifying either
sizeoralignmentor both. I was able to get cues showing up on the left with your sample app by passingLayout.Alignment.ALIGN_NORMALinstead ofcues.get(0).textAlignment.