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
f9162c07
authored
Jul 27, 2021
by
bachinger
Browse files
Options
_('Browse Files')
Download
Plain Diff
Merge pull request #9207 from dlafayet:ruby-position
PiperOrigin-RevId: 386836747
parents
35127558
27576cfc
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
53 additions
and
5 deletions
RELEASENOTES.md
library/core/src/main/java/com/google/android/exoplayer2/text/ttml/TtmlRenderUtil.java
library/core/src/test/java/com/google/android/exoplayer2/text/ttml/TtmlDecoderTest.java
testdata/src/test/assets/media/ttml/rubies.xml
RELEASENOTES.md
View file @
f9162c07
...
...
@@ -106,6 +106,9 @@
*
Extractors:
*
Add support for DTS-UHD in MP4
(
[
#9163
](
https://github.com/google/ExoPlayer/issues/9163
)
.
*
Text:
*
TTML: Inherit the
`rubyPosition`
value from a containing
`<span
ruby="container">`
element.
*
Ad playback:
*
Support changing ad break positions in the player logic
(
[
#5067
](
https://github.com/google/ExoPlayer/issues/5067
)
.
...
...
@@ -128,7 +131,6 @@
`ControlDispatcher`
parameter has also been deprecated in all
`MediaSessionConnector`
listener methods.
### 2.14.2 (2021-07-20)
*
Core Library:
...
...
library/core/src/main/java/com/google/android/exoplayer2/text/ttml/TtmlRenderUtil.java
View file @
f9162c07
...
...
@@ -178,12 +178,22 @@ import java.util.Map;
break
;
}
// TODO: Get rubyPosition from `textNode` when TTML inheritance is implemented.
@Nullable
TtmlStyle
textStyle
=
resolveStyle
(
textNode
.
style
,
textNode
.
getStyleIds
(),
globalStyles
);
// Use position from ruby text node if defined.
@TextAnnotation
.
Position
int
rubyPosition
=
containerNode
.
style
!=
null
?
containerNode
.
style
.
getRubyPosition
()
:
TextAnnotation
.
POSITION_UNKNOWN
;
textStyle
!=
null
?
textStyle
.
getRubyPosition
()
:
TextAnnotation
.
POSITION_UNKNOWN
;
if
(
rubyPosition
==
TextAnnotation
.
POSITION_UNKNOWN
)
{
// If ruby position is not defined, use position info from container node.
@Nullable
TtmlStyle
containerStyle
=
resolveStyle
(
containerNode
.
style
,
containerNode
.
getStyleIds
(),
globalStyles
);
rubyPosition
=
containerStyle
!=
null
?
containerStyle
.
getRubyPosition
()
:
rubyPosition
;
}
builder
.
setSpan
(
new
RubySpan
(
rubyText
,
rubyPosition
),
start
,
end
,
Spanned
.
SPAN_EXCLUSIVE_EXCLUSIVE
);
break
;
...
...
library/core/src/test/java/com/google/android/exoplayer2/text/ttml/TtmlDecoderTest.java
View file @
f9162c07
...
...
@@ -710,6 +710,18 @@ public final class TtmlDecoderTest {
Spanned
sixthCue
=
getOnlyCueTextAtTimeUs
(
subtitle
,
60_000_000
);
assertThat
(
sixthCue
.
toString
()).
isEqualTo
(
"Cue with annotated text."
);
assertThat
(
sixthCue
).
hasNoRubySpanBetween
(
0
,
sixthCue
.
length
());
Spanned
seventhCue
=
getOnlyCueTextAtTimeUs
(
subtitle
,
70_000_000
);
assertThat
(
seventhCue
.
toString
()).
isEqualTo
(
"Cue with annotated text."
);
assertThat
(
seventhCue
)
.
hasRubySpanBetween
(
"Cue with "
.
length
(),
"Cue with annotated"
.
length
())
.
withTextAndPosition
(
"rubies"
,
TextAnnotation
.
POSITION_BEFORE
);
Spanned
eighthCue
=
getOnlyCueTextAtTimeUs
(
subtitle
,
80_000_000
);
assertThat
(
eighthCue
.
toString
()).
isEqualTo
(
"Cue with annotated text."
);
assertThat
(
eighthCue
)
.
hasRubySpanBetween
(
"Cue with "
.
length
(),
"Cue with annotated"
.
length
())
.
withTextAndPosition
(
"rubies"
,
TextAnnotation
.
POSITION_AFTER
);
}
@Test
...
...
testdata/src/test/assets/media/ttml/rubies.xml
View file @
f9162c07
...
...
@@ -7,6 +7,8 @@
<style
id=
"cont"
tts:ruby=
"container"
/>
<style
id=
"base"
tts:ruby=
"base"
/>
<style
id=
"text"
tts:ruby=
"text"
/>
<style
id=
"cont-with-pos-before"
tts:ruby=
"container"
tts:rubyPosition=
"before"
/>
<style
id=
"text-with-pos-after"
tts:ruby=
"text"
tts:rubyPosition=
"after"
/>
</styling>
</head>
<body>
...
...
@@ -76,5 +78,27 @@
text.
</p>
</div>
<div>
<!-- ruby info in style block and ruby position in contpos -->
<p
begin=
"70s"
end=
"78s"
>
Cue with
<span
style=
"cont-with-pos-before"
>
<span
style=
"base"
>
annotated
</span>
<span
style=
"text"
>
rubies
</span>
text.
</span>
</p>
</div>
<div>
<!-- ruby info and position in style block for base and text -->
<p
begin=
"80s"
end=
"88s"
>
Cue with
<span
style=
"cont-with-pos-before"
>
<span
style=
"base"
>
annotated
</span>
<span
style=
"text-with-pos-after"
>
rubies
</span>
text.
</span>
</p>
</div>
</body>
</tt>
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