From fc5eb12e7955e1272f52a90ec25a1a385429a47c Mon Sep 17 00:00:00 2001 From: Arnold Szabo Date: Mon, 1 Oct 2018 22:45:15 +0300 Subject: [PATCH] #4306 - breaking after the first alignment tag is found --- .../exoplayer2/text/subrip/SubripDecoder.java | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/library/core/src/main/java/com/google/android/exoplayer2/text/subrip/SubripDecoder.java b/library/core/src/main/java/com/google/android/exoplayer2/text/subrip/SubripDecoder.java index 492eb60bfc..e50184e403 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/text/subrip/SubripDecoder.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/text/subrip/SubripDecoder.java @@ -80,7 +80,6 @@ public final class SubripDecoder extends SimpleSubtitleDecoder { @Override protected SubripSubtitle decode(byte[] bytes, int length, boolean reset) { ArrayList cues = new ArrayList<>(); - ArrayList tags = new ArrayList<>(); LongArray cueTimesUs = new LongArray(); ParsableByteArray subripData = new ParsableByteArray(bytes, length); String currentLine; @@ -120,6 +119,7 @@ public final class SubripDecoder extends SimpleSubtitleDecoder { } // Read and parse the text. + ArrayList tags = new ArrayList<>(); textBuilder.setLength(0); while (!TextUtils.isEmpty(currentLine = subripData.readLine())) { if (textBuilder.length() > 0) { @@ -131,19 +131,15 @@ public final class SubripDecoder extends SimpleSubtitleDecoder { Spanned text = Html.fromHtml(textBuilder.toString()); Cue cue = null; - boolean alignTagFound = false; - // At end of this loop the clue must be created with the applied tags for (String tag : tags) { // Check if the tag is an alignment tag if (tag.matches(SUBRIP_ALIGNMENT_TAG)) { - - // Based on the specs, in case of the alignment tags only the first appearance counts - if (alignTagFound) continue; - alignTagFound = true; - cue = buildCue(text, tag); + + // Based on the specs, in case of alignment tags only the first appearance counts, so break + break; } }