Hi,
trying to render a page with Ember.js and getting blocked on the usage of window.Audio
var notificationSound = new window.Audio('/path/to.mp3');
notificationSound.play()
Window.Audio is not at all supported, and returns 'Undefined' which prevents to make the .play() call on it.
Locally, I can use a polyfill as workaround, by injecting it at the beginning of the javascript file, but ultimately some basic dummy support for the Audio object is needed. It's ofcourse not needed to play the sound, but at least to fake the support for the operation, otherwise the page rendering fails.
Here is the polyfill I use:
//AUDIO Pollyfil
window.Audio = function(path){
return {
'play':function(){
return new Promise(function(resolve, reject) {
resolve();
});
},
'pause':function(){
//no-op
},
'canPlayType':function(mimne){
//As this just simulates playing audio. We might
//as well claim we support everything.
//Other options are: maybe or empty string
return 'probably';
}
}
}
var k = new window.Audio('yo');
console.log(k.play());
console.log(k.pause());
Best,
Natasha
HTMLAudioElementTest.audio() was added as @NotYetImplemented
Thanks for reporting, fixed in SVN.