【发布时间】:2016-03-29 01:47:51
【问题描述】:
在询问之前尝试了很多事情,但我仍然未能在我的 Ionic 项目中加载声音作为缓冲区。
我不知道这是我的旧版 firefox 浏览器 26 (Fedora 18) 的错误,还是我做错了。
这是我的代码,非常经典的使用 XMLHttpRequest() 为 Web 音频 API 加载 arrayBuffer:
var request = new XMLHttpRequest()
request.open('GET', './sound/mySound.ogg', true)
request.responseType = 'arraybuffer'
request.onload = function() {
audioCtx.decodeAudioData(request.response, function (buffer) {
mainBuffer = buffer
}, function (err) {
console.log(err)
})
}
request.send()
我在控制台中收到此警告消息:
Les données passées à decodeAudioData possèdent du contenu de type 不明白。
而 err 是未定义的
同一段代码在 Apache 服务器中运行良好。
我在这里错过了什么?
我也尝试这样的事情:
$http.get(url, { responseType: 'arraybuffer' }).success(function (data) {
audioCtx.decodeAudioData(data, function (buffer) {
mainBuffer = buffer
}, function (err) {
console.log(err)
})
}, function (err) {
console.log(err)
})
但仍然没有运气。该文件似乎已损坏。好郁闷……
html5 audio 标签返回同样的错误。
Ionic 服务器有问题吗?
有没有办法解决这个问题?
任何建议将不胜感激。
【问题讨论】:
标签: ionic-framework buffer web-audio-api