我的站点使用令牌播放视频文件,如果令牌过期,则文件请求响应为403。
我需要使用视频to和hls捕捉403来创建一个新的令牌。
我试着用视频说明玩家的错误:
player.on('error', function(){})但是这个没抓到403。
有没有办法捕捉HLS错误而不是视频?
发布于 2018-02-22 15:05:13
对于那些仍在努力解决这些问题的人来说,VideoJs现在有一个reloadSourceOnError插件,可以捕捉这些事件。
player.reloadSourceOnError({
// getSource allows you to reload the source object after an error
getSource: (reload) => {
console.log('Perform any auth renewal / asset URL regeneration here ');
/* Call reload() with a fresh source object, asynchronously if you
* want (but the error dialog will show up while you're waiting) */
reload({
src: 'https://example.com/index.m3u8?CloudFront-Policy=xxxx',
type: 'application/x-mpegURL'
});
},
/* Minimum amount of seconds that must pass before another reload
* will be attempted, stops cascading errors */
errorInterval: 5
});https://stackoverflow.com/questions/46999320
复制相似问题