0

I am setting up a visualizer for Icecast, However I am getting the error

Failed to load resource: net::ERR_EMPTY_RESPONSE

On the Icecast config files I have included

<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" />

Yet I continue to get the error.

I am using this to initiate the audio,

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

I am using Visualizer (A JS Thing) to then do the backend work.

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();
};

However still returning the error even though I have enabled it.

The response I am getting from Headers is

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>

I am trying to make a Audio Visualizer for a live radio station. However having troubles due to the Access-Control even though I have set the headers inside the settings.

The script in question: http://www.cssscript.com/minimal-audio-visualizer-with-canvas-and-vanilla-javascript/

denn1s
  • 155
  • 2
  • 11
  • Take a look at my answer here http://stackoverflow.com/questions/31083704/mediaelementaudiosource-outputs-zeroes-due-to-cors-access-restrictions/37806272#37806272 it has an example of headers configuration. – Alex Paramonov Aug 27 '16 at 05:38
  • 1
    You **must** run Icecast version 2.4.1 or newer for custom headers and other things to work properly! You don't mention which version you run. – TBR Aug 27 '16 at 05:51
  • 1
    `On the Icecast config files I have included` - check the browser developer tools network tab to see the actual headers you are receiving – Jaromanda X Aug 27 '16 at 06:53
  • I have updated the main post with what I have tried doing and the new error I am getting from Icecast. Hopefully this can help you try and solve my issue – denn1s Aug 27 '16 at 16:16
  • What port your Icecast instance is running on? – Alex Paramonov Aug 29 '16 at 11:19
  • maybe use "double quotes" on crossorigin='anonymous'? Or add `:8000` if running on port 8000? – Tomachi May 10 '22 at 16:28

0 Answers0