mirror of
https://github.com/Mibew/mibew.git
synced 2025-04-24 07:24:44 +03:00
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:
parent
90e644e9eb
commit
b9492c653d
@ -60,11 +60,14 @@
|
||||
* @param {String} file File path
|
||||
*/
|
||||
Mibew.Utils.playSound = function (file) {
|
||||
var soundHTML = '<audio autoplay style="display: none;">' +
|
||||
'<source src="' + file + '" type="audio/x-wav" />' +
|
||||
'<embed src="' + file + '" type="audio/x-wav" hidden="true" autostart="true" loop="false" />' +
|
||||
'</audio>';
|
||||
$('body').append(soundHTML);
|
||||
if(!document.getElementById("mibew_audio_alert")) {
|
||||
var soundHTML = '<audio autoplay id="mibew_audio_alert" style="display: none;">' +
|
||||
'<source src="' + file + '" type="audio/x-wav" />' +
|
||||
'<embed src="' + file + '" type="audio/x-wav" hidden="true" autostart="true" loop="false" />' +
|
||||
'</audio>';
|
||||
$('body').append(soundHTML);
|
||||
}
|
||||
document.getElementById('mibew_audio_alert').play();
|
||||
}
|
||||
|
||||
})(Mibew, $);
|
Loading…
Reference in New Issue
Block a user