600字范文,内容丰富有趣,生活中的好帮手!
600字范文 > html5播放音频流 html5 – 使用Audio API播放音频流

html5播放音频流 html5 – 使用Audio API播放音频流

时间:2018-12-12 01:37:15

相关推荐

html5播放音频流 html5 – 使用Audio API播放音频流

我正在使用

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

}

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

任何帮助表示赞赏.

谢谢

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。