由于 CORS,Howler.js 无法获取频率数据?

问题描述

问题 - 我无法从网络电台获取频率数据。控制台日志给出了 CORS 问题,但是,我不确定是否真的如此。 为了解决 cors 问题,我尝试使用 Chrome 的 Allow CORS 插件来查看它是否可以工作 - 它没有。同样显然 - 从 Howler 文档 "html5: true" 应该照顾 CORS。 因为我没有 元素,所以我不能使用 crossorigin="anonymous"

我正在尝试 - 从流中获取 getByteFrequencyData,以便从网络电台创建音频可视化工具。

我的代码:

testAnalyzer() {
  var audio = new Howl({
    src: ['https://pool.anison.fm:9000/AniSonFM(320)'],html5: true,volume: this.volume,});

    audio.play();
    const audioCtx = Howler.ctx;
    const audioSourceNode = audioCtx.createMediaElementSource(audio._sounds[0]._node);
    console.log('Audio CTX',audioCtx);

    const analyser = audioCtx.createAnalyser();
    console.log('Audio Source Node - ',audioSourceNode);


    analyser.fftsize = 512;
    const bufferLength = analyser.frequencyBinCount;
    const dataArray = new Uint8Array(bufferLength);

    //Set up audio node network
    audioSourceNode.connect(analyser);
    analyser.connect(audioCtx.destination);

    analyser.getByteFrequencyData(dataArray)
    console.log('Frequency Data - ',dataArray)
}

控制台结果: MediaElementAudioSource outputs zeroes due to CORS access restrictions for https://pool.anison.fm:9000/AniSonFM(320)

我正在使用 Vue2 和 HowlerJS

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)