From ea9ef24ceeb21dd78e4552c94e04c826a57119cb Mon Sep 17 00:00:00 2001 From: bomoko Date: Mon, 26 Jun 2017 20:34:51 +0200 Subject: [PATCH] Applying new loadXX _decrementPreload logic to loadSound --- src/soundfile.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/soundfile.js b/src/soundfile.js index 1ad17e03..4bd8839f 100644 --- a/src/soundfile.js +++ b/src/soundfile.js @@ -182,7 +182,15 @@ define(function (require) { alert('This sketch may require a server to load external files. Please see http://bit.ly/1qcInwS'); } - var s = new p5.SoundFile(path, callback, onerror, whileLoading); + var self = this; + var s = new p5.SoundFile(path, function() { + if(typeof callback === 'function') { + callback.apply(self, arguments); + } + + self._decrementPreload(); + }, onerror, whileLoading); + return s; };