Loading media/java/android/media/WebVttRenderer.java +19 −18 Original line number Diff line number Diff line Loading @@ -558,7 +558,11 @@ class TextTrackCue extends SubtitleTrack.Cue { } } /** @hide */ /** * Supporting July 10 2013 draft version * * @hide */ class WebVttParser { private static final String TAG = "WebVttParser"; private Phase mPhase; Loading Loading @@ -726,16 +730,16 @@ class WebVttParser { "has invalid value", e.getMessage(), value); } } else if (name.equals("lines")) { try { int lines = Integer.parseInt(value); if (lines >= 0) { region.mLines = lines; if (value.matches(".*[^0-9].*")) { log_warning("lines", name, "contains an invalid character", value); } else { log_warning("region setting", name, "is negative", value); } try { region.mLines = Integer.parseInt(value); assert(region.mLines >= 0); // lines contains only digits } catch (NumberFormatException e) { log_warning("region setting", name, "is not numeric", value); } } } else if (name.equals("regionanchor") || name.equals("viewportanchor")) { int commaAt = value.indexOf(","); Loading Loading @@ -872,18 +876,14 @@ class WebVttParser { } } else if (name.equals("line")) { try { int linePosition; /* TRICKY: we know that there are no spaces in value */ assert(value.indexOf(' ') < 0); if (value.endsWith("%")) { linePosition = Integer.parseInt( value.substring(0, value.length() - 1)); if (linePosition < 0 || linePosition > 100) { log_warning("cue setting", name, "is out of range", value); continue; } mCue.mSnapToLines = false; mCue.mLinePosition = linePosition; mCue.mLinePosition = parseIntPercentage(value); } else if (value.matches(".*[^0-9].*")) { log_warning("cue setting", name, "contains an invalid character", value); } else { mCue.mSnapToLines = true; mCue.mLinePosition = Integer.parseInt(value); Loading @@ -892,6 +892,7 @@ class WebVttParser { log_warning("cue setting", name, "is not numeric or percentage", value); } // TODO: add support for optional alignment value [,start|middle|end] } else if (name.equals("position")) { try { mCue.mTextPosition = parseIntPercentage(value); Loading Loading
media/java/android/media/WebVttRenderer.java +19 −18 Original line number Diff line number Diff line Loading @@ -558,7 +558,11 @@ class TextTrackCue extends SubtitleTrack.Cue { } } /** @hide */ /** * Supporting July 10 2013 draft version * * @hide */ class WebVttParser { private static final String TAG = "WebVttParser"; private Phase mPhase; Loading Loading @@ -726,16 +730,16 @@ class WebVttParser { "has invalid value", e.getMessage(), value); } } else if (name.equals("lines")) { try { int lines = Integer.parseInt(value); if (lines >= 0) { region.mLines = lines; if (value.matches(".*[^0-9].*")) { log_warning("lines", name, "contains an invalid character", value); } else { log_warning("region setting", name, "is negative", value); } try { region.mLines = Integer.parseInt(value); assert(region.mLines >= 0); // lines contains only digits } catch (NumberFormatException e) { log_warning("region setting", name, "is not numeric", value); } } } else if (name.equals("regionanchor") || name.equals("viewportanchor")) { int commaAt = value.indexOf(","); Loading Loading @@ -872,18 +876,14 @@ class WebVttParser { } } else if (name.equals("line")) { try { int linePosition; /* TRICKY: we know that there are no spaces in value */ assert(value.indexOf(' ') < 0); if (value.endsWith("%")) { linePosition = Integer.parseInt( value.substring(0, value.length() - 1)); if (linePosition < 0 || linePosition > 100) { log_warning("cue setting", name, "is out of range", value); continue; } mCue.mSnapToLines = false; mCue.mLinePosition = linePosition; mCue.mLinePosition = parseIntPercentage(value); } else if (value.matches(".*[^0-9].*")) { log_warning("cue setting", name, "contains an invalid character", value); } else { mCue.mSnapToLines = true; mCue.mLinePosition = Integer.parseInt(value); Loading @@ -892,6 +892,7 @@ class WebVttParser { log_warning("cue setting", name, "is not numeric or percentage", value); } // TODO: add support for optional alignment value [,start|middle|end] } else if (name.equals("position")) { try { mCue.mTextPosition = parseIntPercentage(value); Loading