【发布时间】:2019-07-03 19:50:00
【问题描述】:
我正在尝试在我的 Angular Web 应用程序中播放一个 mp3 文件。因此,我尝试使用XMLHttpRequest 将其加载到我的组件中,以使其成为ArrayBuffer,如下所示:
public loadFile = () => {
if (this.context === undefined) {
return;
}
this.xhr = new XMLHttpRequest();
this.xhr.open("GET", "./plucky.mp3", true);
this.xhr.responseType = "arraybuffer";
this.xhr.onload = this.onLoadComplete;
this.xhr.send();
}
但我收到了ERROR 404 NOT FOUND,尽管 mp3 位于我的组件的同一文件夹中。如何将其加载为ArrayBuffer?
谢谢。
【问题讨论】:
标签: angular audio xmlhttprequest arraybuffer