File tree 2 files changed +22
-10
lines changed
2 files changed +22
-10
lines changed Original file line number Diff line number Diff line change @@ -48,13 +48,27 @@ import { Player as TonePlayer } from "tone/build/esm/source/buffer/Player.js";
48
48
* </code></div>
49
49
*/
50
50
function loadSound ( path ) {
51
- let player = new p5 . SoundFile (
52
- path ,
53
- function ( ) {
54
- self . _decrementPreload ( ) ;
55
- }
56
- ) ;
57
- return player ;
51
+ if ( self . _incrementPreload && self . _decrementPreload ) {
52
+ self . _incrementPreload ( ) ;
53
+
54
+ let player = new p5 . SoundFile (
55
+ path ,
56
+ function ( ) {
57
+ self . _decrementPreload ( ) ;
58
+ }
59
+ ) ;
60
+ return player ;
61
+
62
+ } else {
63
+ return new Promise ( ( resolve ) => {
64
+ let player = new p5 . SoundFile (
65
+ path ,
66
+ function ( ) {
67
+ resolve ( player ) ;
68
+ }
69
+ ) ;
70
+ } ) ;
71
+ }
58
72
}
59
73
60
74
/**
Original file line number Diff line number Diff line change @@ -51,11 +51,9 @@ p5.Panner = Panner;
51
51
import Panner3D from './Panner3D' ;
52
52
p5 . Panner3D = Panner3D ;
53
53
54
- p5 . prototype . loadSound = loadSound ;
55
- p5 . prototype . registerPreloadMethod ( 'loadSound' , p5 . prototype ) ;
56
-
57
54
import SoundFile , { loadSound } from './SoundFile' ;
58
55
p5 . SoundFile = SoundFile ;
56
+ p5 . prototype . loadSound = loadSound ;
59
57
60
58
import AudioIn from './AudioIn' ;
61
59
p5 . AudioIn = AudioIn ;
You can’t perform that action at this time.
0 commit comments