function SoundBox(){this.sounds={},this.sound_callbacks={},this.load=function(s,n){this.sounds[s]=new Audio(n),this.sounds[s].addEventListener("ended",function(n){n.target.currentTime=0,"function"==typeof this.sound_callbacks[s]&&(this.sound_callbacks[s](s),delete this.sound_callbacks[s])}.bind(this))},this.remove=function(s){"undefined"!=typeof this.sounds&&delete this.sounds[s],"function"==typeof this.sound_callbacks&&delete this.sound_callbacks[s]},this.play=function(s,n){return"undefined"==typeof this.sounds[s]?(console.error("Can't find sound called '"+s+"'."),!1):("function"==typeof n&&(this.sound_callbacks[s]=n),void this.sounds[s].play())}}

@@ -37,51 +37,36 @@
 his.
-sound_callbacks=%7B%7D,this.load=function(s,n)%7B
+load=function(a,b,c)%7Breturn 
 this
@@ -73,17 +73,17 @@
 .sounds%5B
-s
+a
 %5D=new Au
@@ -86,19 +86,45 @@
 w Audio(
-n
+b
 ),
+%22function%22==typeof c?void 
 this.sou
@@ -127,17 +127,17 @@
 .sounds%5B
-s
+a
 %5D.addEve
@@ -152,164 +152,140 @@
 er(%22
-ended%22,function(n)%7Bn.target.currentTime=0,%22function%22==typeof this.sound_callbacks%5Bs%5D&&(this.sound_callbacks%5Bs%5D(s),delete this.sound_callbacks%5Bs%5D)%7D.bind(this
+canplaythrough%22,c):new Promise(d=%3Ethis.sounds%5Ba%5D.addEventListener(%22canplaythrough%22,d),this.sounds%5Ba%5D.addEventListener(%22error%22,reject
 ))%7D,
@@ -305,17 +305,17 @@
 unction(
-s
+a
 )%7B%22undef
@@ -360,17 +360,17 @@
 .sounds%5B
-s
+a
 %5D,%22funct
@@ -432,17 +432,17 @@
 llbacks%5B
-s
+a
 %5D%7D,this.
@@ -459,19 +459,16 @@
 ion(
-s,n)%7Breturn
+a,b)%7Bif(
 %22und
@@ -499,12 +499,18 @@
 nds%5B
-s%5D?(
+a%5D)return 
 cons
@@ -547,17 +547,17 @@
 lled '%22+
-s
+a
 +%22'.%22),!
@@ -561,86 +561,225 @@
 ),!1
-):(%22function%22==typeof n&&(this.sound_callbacks%5Bs%5D=n),void this.sounds%5Bs%5D.play(
+;var c=this.sounds%5Ba%5D.cloneNode(!0);return c.play(),%22function%22==typeof b?(console.log(%22Adding callback%22),c.addEventListener(%22ended%22,b),!0):(console.log(%22Returning promise%22),new Promise(d=%3Ec.addEventListener(%22ended%22,d)
 ))%7D%7D

Update minified version