aboutsummaryrefslogtreecommitdiff
path: root/ext/fg/js/frame.js
diff options
context:
space:
mode:
authorAlex Yatskov <alex@foosoft.net>2017-02-11 12:16:14 -0800
committerAlex Yatskov <alex@foosoft.net>2017-02-11 12:16:14 -0800
commit701c91ea66852631ccc6e7bfb23b49578646ff33 (patch)
tree536cc30e178abdf6c28b47b88a67770250a106bf /ext/fg/js/frame.js
parent7398e74d71a91dfc1397c28f8dc5df4205d96249 (diff)
block placeholder audio with a short audio clip1.0.13
Diffstat (limited to 'ext/fg/js/frame.js')
-rw-r--r--ext/fg/js/frame.js23
1 files changed, 19 insertions, 4 deletions
diff --git a/ext/fg/js/frame.js b/ext/fg/js/frame.js
index 83d6d7ef..ca0636f9 100644
--- a/ext/fg/js/frame.js
+++ b/ext/fg/js/frame.js
@@ -170,12 +170,27 @@ class Frame {
}
for (const key in this.audioCache) {
- this.audioCache[key].pause();
+ const audio = this.audioCache[key];
+ if (audio !== null) {
+ audio.pause();
+ }
}
- const audio = this.audioCache[url] || new Audio(url);
- audio.currentTime = 0;
- audio.play();
+ let audio = this.audioCache[url];
+ if (audio) {
+ audio.currentTime = 0;
+ audio.play();
+ } else {
+ audio = new Audio(url);
+ audio.onloadeddata = () => {
+ if (audio.duration === 5.694694) {
+ audio = new Audio('mp3/button.mp3');
+ }
+
+ this.audioCache[url] = audio;
+ audio.play();
+ };
+ }
}
handleError(error) {