diff --git a/library/core/src/main/java/com/google/android/exoplayer2/text/ssa/SsaDecoder.java b/library/core/src/main/java/com/google/android/exoplayer2/text/ssa/SsaDecoder.java index c14767667a..cd139a45dd 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/text/ssa/SsaDecoder.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/text/ssa/SsaDecoder.java @@ -308,8 +308,8 @@ public final class SsaDecoder extends SimpleSubtitleDecoder { // Apply primary color. if (style != null) { - if (style.primaryColor.isSet) { - spannableText.setSpan(new ForegroundColorSpan(style.primaryColor.value), + if (style.primaryColor.isSet()) { + spannableText.setSpan(new ForegroundColorSpan(style.primaryColor.getColor()), 0, spannableText.length(), SpannableString.SPAN_EXCLUSIVE_EXCLUSIVE); } } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/text/ssa/SsaStyle.java b/library/core/src/main/java/com/google/android/exoplayer2/text/ssa/SsaStyle.java index 6b29904ed6..26c725a1b8 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/text/ssa/SsaStyle.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/text/ssa/SsaStyle.java @@ -31,6 +31,7 @@ import com.google.android.exoplayer2.util.Log; import com.google.android.exoplayer2.util.Util; import java.lang.annotation.Documented; import java.lang.annotation.Retention; +import java.util.NoSuchElementException; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -166,14 +167,25 @@ import java.util.regex.Pattern; public static SsaColor UNSET = new SsaColor(0, false); - public final @ColorInt int value; - public final boolean isSet; + private final @ColorInt int color; + private final boolean isSet; - private SsaColor(@ColorInt int value, boolean isSet) { - this.value = value; + private SsaColor(@ColorInt int color, boolean isSet) { + this.color = color; this.isSet = isSet; } + public @ColorInt int getColor() { + if (!isSet) { + throw new NoSuchElementException("No color is present"); + } + return color; + } + + public boolean isSet() { + return isSet; + } + public static SsaColor from(@ColorInt int value) { return new SsaColor(value, true); } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/util/ColorParser.java b/library/core/src/main/java/com/google/android/exoplayer2/util/ColorParser.java index 7722962262..e8b2f1e77f 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/util/ColorParser.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/util/ColorParser.java @@ -90,7 +90,7 @@ public final class ColorParser { rgbaStringBuilder.insert(2, "0"); } } - abgr = (int) Long.parseLong(colorExpression.substring(2), 16); + abgr = (int) Long.parseLong(rgbaStringBuilder.substring(2), 16); } else { // Parse color from decimal format (bytes order AABBGGRR). abgr = (int) Long.parseLong(colorExpression);