我正在使用

HTML5音频api来播放声音.这适用于普通的mp3文件但是当使用诸如http://95.173.167.24:8009的声音流时,它无法播放.

这是我正在使用的代码:

if('webkitAudioContext' in window) {

var myAudioContext = new webkitAudioContext();

}

request = new XMLHttpRequest();

request.open('GET', 'http://95.173.167.24:8009', true);

request.responseType = 'arraybuffer';

request.addEventListener('load', bufferSound, false);

request.send();

function bufferSound(event) {

var request = event.target;

var source = myAudioContext.createBufferSource();

source.buffer = myAudioContext.createBuffer(request.response, false);

source.connect(myAudioContext.destination);

source.noteOn(0);

}

有人能指出我正确的方向吗?

任何帮助表示赞赏.

谢谢

Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐