Package com.google.android.exoplayer2.text.webvtt

## Class WebvttParserUtil

- java.lang.Object
- - com.google.android.exoplayer2.text.webvtt.WebvttParserUtil

-     public final class WebvttParserUtil
      extends Object

  Utility methods for parsing WebVTT data.

- - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `static Matcher` | `findNextCueHeader​(ParsableByteArray input)` | Reads lines up to and including the next WebVTT cue header.
    `static boolean` | `isWebvttHeaderLine​(ParsableByteArray input)` | Returns whether the given input is the first line of a WebVTT file.
    `static float` | `parsePercentage​(String s)` | Parses a percentage string.
    `static long` | `parseTimestampUs​(String timestamp)` | Parses a WebVTT timestamp.
    `static void` | `validateWebvttHeaderLine​(ParsableByteArray input)` | Reads and validates the first line of a WebVTT file.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Method Detail

    - #### validateWebvttHeaderLine

          public static void validateWebvttHeaderLine​(ParsableByteArray input)
                                               throws ParserException

      Reads and validates the first line of a WebVTT file.
      Parameters:
        `input` - The input from which the line should be read.
      Throws:
        `ParserException` - If the line isn't the start of a valid WebVTT file.

    - #### isWebvttHeaderLine

          public static boolean isWebvttHeaderLine​(ParsableByteArray input)

      Returns whether the given input is the first line of a WebVTT file.
      Parameters:
        `input` - The input from which the line should be read.

    - #### parseTimestampUs

          public static long parseTimestampUs​(String timestamp)
                                       throws NumberFormatException

      Parses a WebVTT timestamp.
      Parameters:
        `timestamp` - The timestamp string.
      Returns:
        The parsed timestamp in microseconds.
      Throws:
        `NumberFormatException` - If the timestamp could not be parsed.

    - #### parsePercentage

          public static float parsePercentage​(String s)
                                       throws NumberFormatException

      Parses a percentage string.
      Parameters:
        `s` - The percentage string.
      Returns:
        The parsed value, where 1.0 represents 100%.
      Throws:
        `NumberFormatException` - If the percentage could not be parsed.

    - #### findNextCueHeader

          @Nullable
          public static Matcher findNextCueHeader​(ParsableByteArray input)

      Reads lines up to and including the next WebVTT cue header.
      Parameters:
        `input` - The input from which lines should be read.
      Returns:
        A `Matcher` for the WebVTT cue header, or null if the end of the input was reached without a cue header being found. In the case that a cue header is found, groups 1, 2 and 3 of the returned matcher contain the start time, end time and settings list.