转:dplayer设置一个自定义header头部
DPlayer只是一个视频播放器,并不直接负责网络请求可以参考以下代码:
let request = new XMLHttpRequest();
request.responseType = 'blob';
request.open('get', 'map4 url', true);
request.setRequestHeader('Authorization', `123456`);
request.onreadystatechange = e => {
if (request.readyState === XMLHttpRequest.DONE && request.status === 200) {
const dp = new DPlayer({
container: document.getElementById('dplayer'),
video: {
url: URL.createObjectURL(request.response),
},
});
}
};
request.send(null);
https://github.com/MoePlayer/DPlayer/issues/956 {:3028:}
页:
[1]