video.js TypeError (of any type) prevents catching errors

Viewed 256

I am using video.js to display an HLS Live Stream. Everything works as expected. But I want to implement a reconnect function if the source goes down. I've found the way to do it, but it requires a certain reaction when a certain error pops up:

var player = videojs('#my-video');
player.on('error', function(event) {
    console.log('Source is down, trying to reconnect...);
    // Check for what error is thrown and if error's
    // code is the needed one - reconnect!
});

The thing is that it sometimes works and sometimes doesn't. The only difference I see is that when it works there are only WARN's displayed in Chrome's DevTools console. Sometimes video.js throws an error VIDEOJS: ERROR: TypeError: Cannot read property 'duration' of undefined because of some malformed data in the HLS playlist, but the stream is kept going on. And, if that error is thrown no other errors can be caught by my script. What am I doing wrong and how can I always catch all errors thrown by video.js?

0 Answers
Related