mozilla / vtt.js

A JavaScript implementation of the WebVTT specification
http://dev.w3.org/html5/webvtt/
Apache License 2.0
484 stars 94 forks source link

Failed to execute 'decode' on 'TextDecoder' #366

Open imerkle opened 7 years ago

imerkle commented 7 years ago

vtt.js:1105 Uncaught TypeError: Failed to execute 'decode' on 'TextDecoder': The provided value is not of type '(ArrayBuffer or ArrayBufferView)' at WebVTT.Parser.parse (vtt.js:1105)


WEBVTT FILE

00:00:04.000 --> 00:00:10.000
4 to 10 seconds im show#xywh=0$^0$^167$^94

00:00:10.004 --> 00:00:16.008
10 to 16 seconds im show#xywh=167$^0$^167$^94

00:00:15.004 --> 00:00:21.000
15 to 21 seconds im show#xywh=167$^0$^167$^94
import v from 'vtt.js';
const getVttCues = (url, callback) => {
  const parser = new v.WebVTT.Parser(window, v.WebVTT.StringDecoder());
  let vtt,
    cues = [];   
  const xhttp = new XMLHttpRequest();
  xhttp.onreadystatechange = function() {
      if (this.readyState == 4 && this.status == 200) {
        vtt = xhttp.responseText;
        console.log(vtt);
        parser.oncue = function(cue) {
          cues.push(cue);
        };
        parser.parse(vtt);
        parser.flush();
        callback(cues);

      }
  };

What weird is I tried in webpackbin it works.!!