Shoutcast + 网络音频 API CORS 问题

Shoutcast + Web Audio API CORS issue

我有一个问题我已经研究了一段时间但没有真正的进展。我目前正在尝试将我的 Shoutcast 流加载到我的网络音频 API 上下文中。我认为它会违反 CORS,我是对的。我尝试通过 XHR 请求,然后再次通过将音频元素加载到脚本中。它与音频元素一起工作,但在尝试将其加载到脚本中时死了。似乎我唯一的选择是尝试以某种方式将 CORS headers 添加到我的 Shoutcast 正在服务的流中。

我不知道该怎么做,也没有在网上找到资源。如果有人能给我一些建议,将不胜感激!

var audioCtx = new (window.AudioContext || window.webkitAudioContext)();
var soundSource, concertHallBuffer;

ajaxRequest = new XMLHttpRequest();

ajaxRequest.open('GET', 'http://127.0.0.1:8000/;stream.mp3', true);

ajaxRequest.responseType = 'arraybuffer';


ajaxRequest.onload = function() {
  var audioData = ajaxRequest.response;
  console.log(audioData);

   audioCtx.decodeAudioData(audioData, function(buffer) {
    concertHallBuffer = buffer;
    soundSource = audioCtx.createBufferSource();
    soundSource.buffer = concertHallBuffer;

    soundSource.connect(audioCtx.destination);
    soundSource.loop = true;
    soundSource.start();
  }, function(e){"Error with decoding audio data" + e.err});
}

ajaxRequest.send();

只是回答我自己的问题。通过在指向我的 shoutcast 流和端口的 apache 中设置反向代理,我能够使 shoutcast 流正常工作。