use of com.google.android.exoplayer2.text.Subtitle in project ExoPlayer by google.
the class TtmlDecoderTest method testFontSizeSpans.
public void testFontSizeSpans() throws IOException, SubtitleDecoderException {
TtmlSubtitle subtitle = getSubtitle(FONT_SIZE_TTML_FILE);
assertEquals(10, subtitle.getEventTimeCount());
List<Cue> cues = subtitle.getCues(10 * 1000000);
assertEquals(1, cues.size());
SpannableStringBuilder spannable = (SpannableStringBuilder) cues.get(0).text;
assertEquals("text 1", String.valueOf(spannable));
assertAbsoluteFontSize(spannable, 32);
cues = subtitle.getCues(20 * 1000000);
assertEquals(1, cues.size());
spannable = (SpannableStringBuilder) cues.get(0).text;
assertEquals("text 2", String.valueOf(cues.get(0).text));
assertRelativeFontSize(spannable, 2.2f);
cues = subtitle.getCues(30 * 1000000);
assertEquals(1, cues.size());
spannable = (SpannableStringBuilder) cues.get(0).text;
assertEquals("text 3", String.valueOf(cues.get(0).text));
assertRelativeFontSize(spannable, 1.5f);
cues = subtitle.getCues(40 * 1000000);
assertEquals(1, cues.size());
spannable = (SpannableStringBuilder) cues.get(0).text;
assertEquals("two values", String.valueOf(cues.get(0).text));
assertAbsoluteFontSize(spannable, 16);
cues = subtitle.getCues(50 * 1000000);
assertEquals(1, cues.size());
spannable = (SpannableStringBuilder) cues.get(0).text;
assertEquals("leading dot", String.valueOf(cues.get(0).text));
assertRelativeFontSize(spannable, 0.5f);
}
use of com.google.android.exoplayer2.text.Subtitle in project ExoPlayer by google.
the class TtmlDecoderTest method testFontSizeWithEmptyValueIsIgnored.
public void testFontSizeWithEmptyValueIsIgnored() throws IOException, SubtitleDecoderException {
TtmlSubtitle subtitle = getSubtitle(FONT_SIZE_EMPTY_TTML_FILE);
assertEquals(2, subtitle.getEventTimeCount());
List<Cue> cues = subtitle.getCues(10 * 1000000);
assertEquals(1, cues.size());
SpannableStringBuilder spannable = (SpannableStringBuilder) cues.get(0).text;
assertEquals("empty", String.valueOf(spannable));
assertEquals(0, spannable.getSpans(0, spannable.length(), RelativeSizeSpan.class).length);
assertEquals(0, spannable.getSpans(0, spannable.length(), AbsoluteSizeSpan.class).length);
}
use of com.google.android.exoplayer2.text.Subtitle in project ExoPlayer by google.
the class TtmlDecoderTest method testFontSizeWithMissingUnitIsIgnored.
public void testFontSizeWithMissingUnitIsIgnored() throws IOException, SubtitleDecoderException {
TtmlSubtitle subtitle = getSubtitle(FONT_SIZE_MISSING_UNIT_TTML_FILE);
assertEquals(2, subtitle.getEventTimeCount());
List<Cue> cues = subtitle.getCues(10 * 1000000);
assertEquals(1, cues.size());
SpannableStringBuilder spannable = (SpannableStringBuilder) cues.get(0).text;
assertEquals("no unit", String.valueOf(spannable));
assertEquals(0, spannable.getSpans(0, spannable.length(), RelativeSizeSpan.class).length);
assertEquals(0, spannable.getSpans(0, spannable.length(), AbsoluteSizeSpan.class).length);
}
use of com.google.android.exoplayer2.text.Subtitle in project ExoPlayer by google.
the class Mp4WebvttDecoderTest method testSingleCueSample.
// Positive tests.
public void testSingleCueSample() throws SubtitleDecoderException {
Mp4WebvttDecoder decoder = new Mp4WebvttDecoder();
Subtitle result = decoder.decode(SINGLE_CUE_SAMPLE, SINGLE_CUE_SAMPLE.length);
// Line feed must be trimmed by the decoder
Cue expectedCue = new Cue("Hello World");
assertMp4WebvttSubtitleEquals(result, expectedCue);
}
use of com.google.android.exoplayer2.text.Subtitle in project ExoPlayer by google.
the class Mp4WebvttDecoderTest method testNoCueSample.
public void testNoCueSample() throws SubtitleDecoderException {
Mp4WebvttDecoder decoder = new Mp4WebvttDecoder();
Subtitle result = decoder.decode(NO_CUE_SAMPLE, NO_CUE_SAMPLE.length);
assertMp4WebvttSubtitleEquals(result);
}
Aggregations