Skip to content
This repository was archived by the owner on Feb 22, 2024. It is now read-only.

Sara / Checked play promise #3487

Merged
merged 9 commits into from
Dec 22, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Checked play promise
  • Loading branch information
sara-fs committed Dec 8, 2021
commit 3610ac8ba4dff9d674d3bc2fd998f0ce9f979852
11 changes: 9 additions & 2 deletions src/botPage/view/blockly/customBlockly.js
Original file line number Diff line number Diff line change
Expand Up @@ -368,8 +368,15 @@ 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();
if (playPromise !== undefined) {
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) {
Expand Down
9 changes: 8 additions & 1 deletion src/botPage/view/logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(() => {});
}
}
};

Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

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:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy