@svta/common-media-library
    Preparing search index...

    Function parseWebVtt

    • Beta

      Parse a WebVTT string into a WebVttParseResult.

      Parameters

      • text: string

        The WebVTT string to parse.

      • Optionaloptions: WebVttParserOptions

        The options to use for the parser.

      Returns WebVttParseResult

      The parsed WebVttParseResult.

      const vtt = `WEBVTT\n\nREGION\nid:test\n\nSTYLE\n::cue {}\n\nCUE_1\n00:00:00.000 --> 00:00:35.000\nWevVTT Sample\n`;

      const { cues, errors, regions, styles } = parseWebVtt(vtt);

      assert(cues[0].id === 'CUE_1');
      assert(cues[0].text === 'WevVTT Sample');
      assert(errors.length === 0);
      assert(regions[0].id === 'test');
      assert(styles.length === 1);