I'm using Web Audio API to do a simple streaming audio using this function: function MyAudio(url){ var song = new Audio(); song.crossOrigin = "anonymous"; song.src = url;
this.source = context.createMediaElementSource(song);
this.source.connect(context.destination);
}
MyAudio.prototype.play = function(){
this.source.mediaElement.play();
};
return MyAudio;
});
But I can't figure out how to pause or stop it. I saw other questions here but they use noteOn/noteOff and that doesn't work in my case.
I have tried without success things like:
MyAudio.prototype.stop = function(){
this.source.mediaElement.noteOff();
};
MyAudio.prototype.stop = function(){
this.source.mediaElement.Stop();
};
MyAudio.prototype.stop = function(){
this.source.stop(0);
};
No luck.