Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
SDK
/
exoplayer
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
262f19aa
authored
Apr 01, 2020
by
ibaker
Committed by
Oliver Woodman
Apr 01, 2020
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Add vertical text support to SubtitleWebView
PiperOrigin-RevId: 304186326
parent
eb65f5e2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
0 deletions
library/ui/src/main/java/com/google/android/exoplayer2/ui/SubtitleWebView.java
library/ui/src/main/java/com/google/android/exoplayer2/ui/SubtitleWebView.java
View file @
262f19aa
...
...
@@ -212,6 +212,19 @@ import java.util.List;
String
textAlign
=
convertAlignmentToCss
(
cue
.
textAlignment
);
String
writingMode
=
convertVerticalTypeToCss
(
cue
.
verticalType
);
// All measurements are done orthogonally for vertical text (i.e. from left of screen instead
// of top, or vice versa). So flip the position & translation values.
if
(
cue
.
verticalType
==
Cue
.
VERTICAL_TYPE_LR
||
cue
.
verticalType
==
Cue
.
VERTICAL_TYPE_RL
)
{
float
tmpFloat
=
horizontalPositionPercent
;
horizontalPositionPercent
=
verticalPositionPercent
;
verticalPositionPercent
=
tmpFloat
;
int
tmpInt
=
horizontalTranslatePercent
;
horizontalTranslatePercent
=
verticalTranslatePercent
;
verticalTranslatePercent
=
tmpInt
;
}
html
.
append
(
Util
.
formatInvariant
(
"<div style=\""
...
...
@@ -220,12 +233,14 @@ import java.util.List;
+
"top:%.2f%%;"
+
"width:%s;"
+
"text-align:%s;"
+
"writing-mode:%s;"
+
"transform:translate(%s%%,%s%%);"
+
"\">"
,
horizontalPositionPercent
,
verticalPositionPercent
,
width
,
textAlign
,
writingMode
,
horizontalTranslatePercent
,
verticalTranslatePercent
))
.
append
(
SpannedToHtmlConverter
.
convert
(
cue
.
text
))
...
...
@@ -241,6 +256,18 @@ import java.util.List;
"base64"
);
}
private
String
convertVerticalTypeToCss
(
@Cue
.
VerticalType
int
verticalType
)
{
switch
(
verticalType
)
{
case
Cue
.
VERTICAL_TYPE_LR
:
return
"vertical-lr"
;
case
Cue
.
VERTICAL_TYPE_RL
:
return
"vertical-rl"
;
case
Cue
.
TYPE_UNSET
:
default
:
return
"horizontal-tb"
;
}
}
private
String
convertAlignmentToCss
(
@Nullable
Layout
.
Alignment
alignment
)
{
if
(
alignment
==
null
)
{
return
"unset"
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment