Icecast Stream返回错误No' Access-Control-Allow-Origin'标头出现在请求的资源上

时间:2016-08-27 02:58:03

标签: javascript server cross-domain icecast

我正在为Icecast设置一个可视化工具,但是我收到了错误

Failed to load resource: net::ERR_EMPTY_RESPONSE

在我已包含的Icecast配置文件中

<header name="Access-Control-Allow-Origin" value="*" />
    <header name="Access-Control-Allow-Headers" value="Origin, Accept, X-Requested-With, Content-Type, If-Modified-Since" />
    <header name="Access-Control-Allow-Methods" value="GET, OPTIONS, HEAD" />

然而我继续得到错误。

我用它来启动音频,

  <audio id="myAudio" crossorigin='anonymous' src="http://127.0.0.1/radio.ogg"></audio>

我正在使用Visualizer(A JS Thing)来完成后端工作。

Visualizer.prototype.loadSound = function () {
    var req = new XMLHttpRequest();
    req.setRequestHeader("crossorigin", "anonymous");
    req.open('GET', this.audioSrc, true);
    req.responseType = 'arraybuffer';
    this.canvasCtx.fillText('Loading...', this.canvas.width / 2 + 10, this.canvas.height / 2);

    req.onload = function () {
        this.ctx.decodeAudioData(req.response, this.playSound.bind(this), this.onError.bind(this));
    }.bind(this);

    req.send();
};

然而,即使我启用了它,仍会返回错误。

我从Headers获得的回复是

&#13;
&#13;
HTTP/1.0 400 Bad Request
Server: Icecast 2.4.2
Date: Sat, 27 Aug 2016 16:16:19 GMT
Content-Type: text/html; charset=utf-8
Cache-Control: no-cache
Expires: Mon, 26 Jul 1997 05:00:00 GMT
Pragma: no-cache
Access-Control-Allow-Origin: *
Access-Control-Allow-Headers: Origin, Accept, X-Requested-With, Content-Type, If
-Modified-Since
Access-Control-Allow-Methods: GET, OPTIONS, HEAD

<html><head><title>Error 400</title></head><body><b>400 - unknown request</b></b
ody></html>
&#13;
&#13;
&#13;

我正在为一个直播电台制作一个Audio Visualizer。但是由于Access-Control而导致出现问题,即使我已在设置中设置了标题。

相关剧本:http://www.cssscript.com/minimal-audio-visualizer-with-canvas-and-vanilla-javascript/

0 个答案:

没有答案