video.js TypeError任何类型可防止捕获错误

问题描述

我正在使用 video.js 显示 HLS 实时流。一切都按预期工作。但是如果源出现故障,我想实现重新连接功能。我已经找到了方法,但是当弹出某个错误时需要一定的反应:

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!
});

问题是它有时有效,有时无效。我看到的唯一区别是,当它工作时,Chrome 的 DevTools 控制台中只显示 WARN's。有时,由于 HLS 播放列表中的某些格式错误的数据,video.js 会抛出错误 VIDEOJS: ERROR: TypeError: Cannot read property 'duration' of undefined,但流仍在继续。而且,如果抛出该错误,我的脚本将无法捕获其他错误。我做错了什么,我如何才能始终捕获 video.js 抛出的所有错误

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)