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
ea1ab674
authored
Oct 01, 2014
by
ojw28
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Strip trailing newline from WebVTT subtitles.
parent
9fc963ac
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
3 deletions
library/src/main/java/com/google/android/exoplayer/text/webvtt/WebvttSubtitle.java
library/src/main/java/com/google/android/exoplayer/text/webvtt/WebvttSubtitle.java
View file @
ea1ab674
...
...
@@ -79,15 +79,21 @@ public class WebvttSubtitle implements Subtitle {
@Override
public
String
getText
(
long
timeUs
)
{
StringBuilder
s
ubtitleS
tringBuilder
=
new
StringBuilder
();
StringBuilder
stringBuilder
=
new
StringBuilder
();
for
(
int
i
=
0
;
i
<
cueTimesUs
.
length
;
i
+=
2
)
{
if
((
cueTimesUs
[
i
]
<=
timeUs
)
&&
(
timeUs
<
cueTimesUs
[
i
+
1
]))
{
s
ubtitleS
tringBuilder
.
append
(
cueText
[
i
/
2
]);
stringBuilder
.
append
(
cueText
[
i
/
2
]);
}
}
return
(
subtitleStringBuilder
.
length
()
>
0
)
?
subtitleStringBuilder
.
toString
()
:
null
;
int
stringLength
=
stringBuilder
.
length
();
if
(
stringLength
>
0
&&
stringBuilder
.
charAt
(
stringLength
-
1
)
==
'\n'
)
{
// Adjust the length to remove the trailing newline character.
stringLength
-=
1
;
}
return
stringLength
==
0
?
null
:
stringBuilder
.
substring
(
0
,
stringLength
);
}
}
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