hls.js icon indicating copy to clipboard operation
hls.js copied to clipboard

bug:m3u8 Credential and cros hls parse error

Open wych1987 opened this issue 8 years ago • 1 comments

when my m3u8.live is need cros and Credential ,the xhr-loader need set withCredentials ex: mdn url https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/withCredentials so the

src/utils/xhr-loader.js

// line 45 should set

 xhr = this.loader = new XMLHttpRequest()
xhr.withCredentials = true;

and

src/controller/eme-controller.js

//line 329 should set

let xhr = new XMLHttpRequest();
xhr.withCredentials = true;

tips: xhr go out ,shud use fetch

thx.

wych1987 avatar Nov 13 '18 10:11 wych1987

Chinese: 当我的m3u8直播流跨域访问,并且需要校验权限的时候,hls.js 会出现解析流错误,这是因为hls的内部的xhr解析没有设置跨域授权的头,mdn地址如下 https://developer.mozilla.org/zh-CN/docs/Web/HTTP/Access_control_CORS

因此需要修改内部代码加上

 xhr.withCredentials = true;

当然你可以下载debug的js自己修改对应的地方,全局搜索 var xhr = new eme_controller_XMLHttpRequest() 和 new XMLHttpRequest() 然后自行修改就好了

wych1987 avatar Nov 13 '18 10:11 wych1987