diff --git a/src/botPage/view/blockly/customBlockly.js b/src/botPage/view/blockly/customBlockly.js index a2da174a43..c31db88d17 100644 --- a/src/botPage/view/blockly/customBlockly.js +++ b/src/botPage/view/blockly/customBlockly.js @@ -364,12 +364,41 @@ Blockly.Toolbox.TreeNode.prototype.onClick_ = function(_e) { * Preload all the audio files so that they play quickly when asked for. * @package */ + +Blockly.WorkspaceAudio.prototype.load = function(filenames, name) { + if (!filenames.length) { + return; + } + try { + var audioTest = new window['Audio'](); + } catch (e) { + return; + } + let sound; + + filenames.forEach(filename => { + if (filename.includes('delete') || filename.includes('click') || filename.includes('disconnect')) { + filename = filename.replace('https://blockly-demo.appspot.com/static/media/', 'sound/'); + } + let ext = filename.match(/\.(\w+)$/); + if (ext && audioTest.canPlayType('audio/' + ext[1])) { + sound = new window['Audio'](filename); + } + }); + if (sound?.play) { + this.SOUNDS_[name] = sound; + } +}; Blockly.WorkspaceAudio.prototype.preload = function() { for (var name in this.SOUNDS_) { var sound = this.SOUNDS_[name]; sound.volume = 0.01; - sound.play().catch(function() {}); - sound.pause(); + const playPromise = sound.play(); + playPromise + ?.then(() => { + sound.pause(); + }) + .catch(() => {}); // iOS can only process one sound at a time. Trying to load more than one // corrupts the earlier ones. Just load one and leave the others uncached. if (goog.userAgent.IPAD || goog.userAgent.IPHONE) { diff --git a/src/botPage/view/logger.js b/src/botPage/view/logger.js index c7168a5aa3..8eb246cf67 100644 --- a/src/botPage/view/logger.js +++ b/src/botPage/view/logger.js @@ -20,9 +20,16 @@ const notify = ({ className, message, position = 'left', sound = 'silent' }) => $.notify(message.toString(), { position: `bottom ${position}`, className }); if (sound !== 'silent') { - $(`#${sound}`) + const playPromise = $(`#${sound}`) .get(0) .play(); + if (playPromise !== undefined) { + playPromise + .then(() => { + sound.pause(); + }) + .catch(() => {}); + } } }; diff --git a/static/.DS_Store b/static/.DS_Store index 40bcf3c8c6..15a638e519 100644 Binary files a/static/.DS_Store and b/static/.DS_Store differ diff --git a/static/sound/click.mp3 b/static/sound/click.mp3 new file mode 100644 index 0000000000..4534b0ddca Binary files /dev/null and b/static/sound/click.mp3 differ diff --git a/static/sound/click.ogg b/static/sound/click.ogg new file mode 100644 index 0000000000..e8ae42a610 Binary files /dev/null and b/static/sound/click.ogg differ diff --git a/static/sound/click.wav b/static/sound/click.wav new file mode 100644 index 0000000000..41a50cd76f Binary files /dev/null and b/static/sound/click.wav differ diff --git a/static/sound/delete.mp3 b/static/sound/delete.mp3 new file mode 100644 index 0000000000..442bd9c1f4 Binary files /dev/null and b/static/sound/delete.mp3 differ diff --git a/static/sound/delete.ogg b/static/sound/delete.ogg new file mode 100644 index 0000000000..67f84ac19a Binary files /dev/null and b/static/sound/delete.ogg differ diff --git a/static/sound/delete.wav b/static/sound/delete.wav new file mode 100644 index 0000000000..18debcf96d Binary files /dev/null and b/static/sound/delete.wav differ diff --git a/static/sound/disconnect.mp3 b/static/sound/disconnect.mp3 new file mode 100644 index 0000000000..8cfaff6c06 Binary files /dev/null and b/static/sound/disconnect.mp3 differ diff --git a/static/sound/disconnect.ogg b/static/sound/disconnect.ogg new file mode 100644 index 0000000000..467b527b4d Binary files /dev/null and b/static/sound/disconnect.ogg differ diff --git a/static/sound/disconnect.wav b/static/sound/disconnect.wav new file mode 100644 index 0000000000..af5c25447c Binary files /dev/null and b/static/sound/disconnect.wav differ
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: