如何使用解码AudioBuffer数据设置为源HTMLAudioElement?
让我们假设我们有一个HTMLAudioElement:
let audio = new Audio();
我们还能够接收和解码音频数据:
let context = new AudioContext();
let source = context.createBufferSource(); //this represents the audio source. We need to now populate it with binary data.
Api.getAudioFile(url).then((data) => {
context.decodeAudioData(data, (buffer) => {
source.buffer = buffer;
}, null);
});
如何将其source用作 的来源audio?我认为我必须为此创建一个MediaStream对象,但不太清楚如何去做。