code crashes on MS Edge
vgrafe opened this issue · comments
Hi,
It looks like the WebVTT lib assumes the existence of VTTCue
in the window
object passed in its constructor (and possibly VTTRegion), but it is not always true, i.e. when import
ing the lib ES6 style and under MS Edge.
In those conditions, the WebVTT parser internal parse
method throws an exception: "Object doesn't support this operation", happening there for VTTCue
.
In my scenario, I found a workaround - set VTTCue as a prop on the window object manually:
import { WebVTT, VTTCue } from 'vtt.js'
// the following line needs to happen before injecting the `window` object into the Parser constructor
window.VTTCue = VTTCue;
const parser = new WebVTT.Parser(window, WebVTT.StringDecoder());
// no more error upon parsing!
I'll be happy to submit a PR if needed.
I had the same issue, but window.VTTCue = VTTCue;
fixed that error. Your code works fine for me with the newest version 0.13.0.
2018 checking in. just confirming that this is still an issue. but much like those above, I took the quick fix route (which worked, thanks!) and moved on. sorry world. :)
I had the same issue but with this way now it is working in 0.13.0 version, thank you so match I research too much but finally, it is working 😄 😃
2022 and this saved me too. Thank you for sharing this <3