Trying to add a stop function to the Audio object in javascript like this
//Give the Audio object a stop function
Audio.prototype.stop = function()
{
this.pause();
this.currentTime = 0.0;
}
can be used like this
var aud = new Audio();
aud.src = 'background.ogg';
aud.play();
aud.stop();
Works in Google Chrome, but not in firefox. any ideas ?
Creating an element with
new Audiocreates an element whose prototype isHTMLAudioElement.prototype. Per spec this should be the same object asAudio.prototype, but I believe Firefox doesn’t implement that part of WebIDL yet.In any case, setting your stuff on
HTMLAudioElement.prototypeshould work in both browsers, I would think.