Add ogg/vorbis option for audio files

This commit is contained in:
Fedor A. Fetisov 2021-08-29 23:02:02 +03:00
parent eeb660293c
commit 5c2743c01a
5 changed files with 4 additions and 2 deletions

View File

@ -102,7 +102,7 @@
};
/**
* Play .wav or .mp3 sound file
* Play .wav, or .mp3, or .ogg sound file
* @param {String} file File path (without extension)
*/
Mibew.Utils.playSound = function (file) {
@ -114,6 +114,7 @@
var audioTag = $("<audio>", {autoplay: true, style: "display: none"}).append(
'<source src="' + file + '.wav" type="audio/x-wav" />' +
'<source src="' + file + '.mp3" type="audio/mpeg" codecs="mp3" />' +
'<source src="' + file + '.ogg" type="audio/ogg" codecs="vorbis" />' +
'<embed src="' + file + '.wav" type="audio/x-wav" hidden="true" autostart="true" loop="false" />'
);
$('body').append(audioTag);

View File

@ -393,7 +393,8 @@ var Mibew = Mibew || {};
sound.setAttribute('id', 'mibew-notification-sound');
sound.setAttribute('style', 'display: none;');
sound.innerHTML = '<source src="' + soundFile + '.wav" type="audio/x-wav" />'
+ '<source src="' + soundFile + '.mp3" type="audio/mpeg" codecs="mp3" />';
+ '<source src="' + soundFile + '.mp3" type="audio/mpeg" codecs="mp3" />'
+ '<source src="' + soundFile + '.ogg" type="audio/ogg" codecs="vorbis" />';
document.getElementsByTagName('body')[0].appendChild(sound);
}
// User should do something on a page before it could be possible to play sound, so just try

BIN
src/mibew/sounds/invite.ogg Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.