Mibew.Utils.playSound

Update playSound function it should not have to create new audio element
every time. Just calls the play function when ever playing sound.
This commit is contained in:
ha99y 2013-09-20 00:09:30 -07:00
parent 90e644e9eb
commit b9492c653d

View File

@ -60,11 +60,14 @@
* @param {String} file File path * @param {String} file File path
*/ */
Mibew.Utils.playSound = function (file) { Mibew.Utils.playSound = function (file) {
var soundHTML = '<audio autoplay style="display: none;">' + if(!document.getElementById("mibew_audio_alert")) {
'<source src="' + file + '" type="audio/x-wav" />' + var soundHTML = '<audio autoplay id="mibew_audio_alert" style="display: none;">' +
'<embed src="' + file + '" type="audio/x-wav" hidden="true" autostart="true" loop="false" />' + '<source src="' + file + '" type="audio/x-wav" />' +
'</audio>'; '<embed src="' + file + '" type="audio/x-wav" hidden="true" autostart="true" loop="false" />' +
$('body').append(soundHTML); '</audio>';
$('body').append(soundHTML);
}
document.getElementById('mibew_audio_alert').play();
} }
})(Mibew, $); })(Mibew, $);