How one can use decoded AudioBuffer
data to be set as a source for HTMLAudioElement
?
Let us assume we have an HTMLAudioElement
:
let audio = new Audio();
And we also were able to receive and decode audio data:
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);
});
How one can use source
as a source for an audio
? I assume I have to create a MediaStream
object for that matter, but it's not quite clear how to do it.