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
b692d9fa
authored
Jan 02, 2017
by
Julian Cable
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
tidy and make compatible with test.
parent
e99ad278
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
5 additions
and
39 deletions
library/src/androidTest/java/com/google/android/exoplayer2/text/ssa/SSATests.java
library/src/main/java/com/google/android/exoplayer2/text/ssa/SSADecoder.java
library/src/main/java/com/google/android/exoplayer2/text/ssa/SSASubtitle.java
library/src/main/java/com/google/android/exoplayer2/text/ssa/Style.java
library/src/androidTest/java/com/google/android/exoplayer2/text/ssa/SSATests.java
View file @
b692d9fa
...
...
@@ -18,7 +18,7 @@ public class SSATests extends InstrumentationTestCase {
public
void
testDecodeTypical
()
throws
IOException
{
SSADecoder
decoder
=
new
SSADecoder
();
byte
[]
bytes
=
TestUtil
.
getByteArray
(
getInstrumentation
(),
TYPICAL_FILE
);
SSASubtitle
subtitle
=
decoder
.
decode
(
bytes
,
bytes
.
length
);
SSASubtitle
subtitle
=
decoder
.
decode
File
(
bytes
,
bytes
.
length
);
int
n
=
subtitle
.
getEventTimeCount
();
assertEquals
(
462
,
n
);
assertTypicalCue1
(
subtitle
,
0
);
...
...
library/src/main/java/com/google/android/exoplayer2/text/ssa/SSADecoder.java
View file @
b692d9fa
package
com
.
google
.
android
.
exoplayer2
.
text
.
ssa
;
import
android.content.Intent
;
import
android.text.Layout
;
import
android.util.ArrayMap
;
import
android.util.Log
;
import
com.google.android.exoplayer2.C
;
import
com.google.android.exoplayer2.text.Cue
;
import
com.google.android.exoplayer2.text.SimpleSubtitleDecoder
;
import
com.google.android.exoplayer2.util.LongArray
;
import
com.google.android.exoplayer2.util.ParsableBitArray
;
import
com.google.android.exoplayer2.util.ParsableByteArray
;
import
java.io.UnsupportedEncodingException
;
import
java.text.SimpleDateFormat
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.L
ist
;
import
java.util.L
ocale
;
import
java.util.Map
;
import
static
android
.
R
.
attr
.
breadCrumbShortTitle
;
import
static
android
.
R
.
attr
.
data
;
import
static
android
.
R
.
attr
.
format
;
import
static
android
.
R
.
attr
.
key
;
import
static
android
.
R
.
attr
.
lines
;
import
static
android
.
R
.
attr
.
subtitle
;
import
static
android
.
R
.
attr
.
text
;
import
static
android
.
R
.
attr
.
textAlignment
;
import
static
android
.
R
.
attr
.
track
;
import
static
android
.
icu
.
lang
.
UCharacter
.
GraphemeClusterBreak
.
L
;
import
static
android
.
webkit
.
ConsoleMessage
.
MessageLevel
.
LOG
;
import
static
com
.
google
.
android
.
exoplayer2
.
text
.
Cue
.
DIMEN_UNSET
;
import
static
com
.
google
.
android
.
exoplayer2
.
text
.
Cue
.
TYPE_UNSET
;
/**
* Created by cablej01 on 26/12/2016.
*/
...
...
@@ -115,7 +93,7 @@ public class SSADecoder extends SimpleSubtitleDecoder {
return
subtitle
;
}
public
void
decodeFile
(
byte
[]
bytes
,
int
length
)
{
public
SSASubtitle
decodeFile
(
byte
[]
bytes
,
int
length
)
{
SSASubtitle
subtitle
=
new
SSASubtitle
();
ParsableByteArray
data
=
new
ParsableByteArray
(
bytes
,
length
);
decodeHeader
(
data
);
...
...
@@ -138,6 +116,7 @@ public class SSADecoder extends SimpleSubtitleDecoder {
}
}
}
return
subtitle
;
}
public
void
decodeHeader
(
byte
[]
bytes
,
int
length
)
{
...
...
@@ -156,13 +135,10 @@ public class SSADecoder extends SimpleSubtitleDecoder {
if
(
currentLine
.
equals
(
"[Script Info]"
))
{
// TODO
continue
;
}
else
if
(
currentLine
.
equals
(
"[V4+ Styles]"
))
{
parseStyles
(
styles
,
data
);
continue
;
}
else
if
(
currentLine
.
equals
(
"[V4 Styles]"
))
{
parseStyles
(
styles
,
data
);
continue
;
}
else
if
(
currentLine
.
equals
(
"[Events]"
))
{
break
;
}
...
...
@@ -245,7 +221,7 @@ public class SSADecoder extends SimpleSubtitleDecoder {
long
hours
=
minutes
/
60
;
minutes
-=
60
*
hours
;
double
sec
=
seconds
+
((
float
)
us
)/
1000000.0
;
return
String
.
format
(
"%01d:%02d:%06.3f"
,
hours
,
minutes
,
sec
);
return
String
.
format
(
Locale
.
US
,
"%01d:%02d:%06.3f"
,
hours
,
minutes
,
sec
);
}
public
static
long
parseTimecode
(
String
time
)
{
...
...
library/src/main/java/com/google/android/exoplayer2/text/ssa/SSASubtitle.java
View file @
b692d9fa
package
com
.
google
.
android
.
exoplayer2
.
text
.
ssa
;
import
android.text.Layout
;
import
android.util.Log
;
import
com.google.android.exoplayer2.C
;
import
com.google.android.exoplayer2.text.Cue
;
import
com.google.android.exoplayer2.text.Subtitle
;
import
com.google.android.exoplayer2.util.Assertions
;
import
com.google.android.exoplayer2.util.LongArray
;
import
com.google.android.exoplayer2.util.Util
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.Map
;
import
static
android
.
R
.
attr
.
start
;
/**
* Created by cablej01 on 26/12/2016.
*/
...
...
library/src/main/java/com/google/android/exoplayer2/text/ssa/Style.java
View file @
b692d9fa
package
com
.
google
.
android
.
exoplayer2
.
text
.
ssa
;
import
android.graphics.Outline
;
import
java.util.Map
;
import
static
android
.
os
.
Build
.
VERSION_CODES
.
M
;
/**
* Created by cablej01 on 27/12/2016.
*/
...
...
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