![](/img/trans.png)
[英]How can I make hls.js send the cookie in request header upon requesting encryption key
[英]HLS.js required send http header
<script src="https://cdn.jsdelivr.net/npm/hls.js@latest"></script>
<video id="video" controls></video>
<script>
if (Hls.isSupported()) {
const video = document.getElementById('video');
const hls = new Hls();
hls.attachMedia(video);
hls.on(Hls.Events.MEDIA_ATTACHED, function () {
hls.loadSource("http://foo.com/abc.m3u8");
});
}
</script>
http header
id: 123
token: 456
我有一个视频需要链接到API,这个API需要从HTTP标头发送id和令牌。
有谁知道如何将HTTP标头添加到HLS.js?
尝试使用xhrSetup
。
const hls = new Hls({ xhrSetup: xhr => { xhr.setRequestHeader('id', 1) xhr.setRequestHeader('token', 456) } })
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.