Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

loadSound Callbacks Not Triggering #26

Open
SableRaf opened this issue Aug 27, 2024 · 1 comment
Open

loadSound Callbacks Not Triggering #26

SableRaf opened this issue Aug 27, 2024 · 1 comment

Comments

@SableRaf
Copy link

The loadSound() function's callbacks (success, error, and whileLoading) aren't being triggered as expected in the p5.sound prerelease. This prevents handling events during the loading process and confirming a successful or failed load.

Function Signature

loadSound(path, [successCallback], [errorCallback], [whileLoading])

Example

let player;

function preload() {
  player = loadSound(
    'https://tonejs.github.io/audio/berklee/gong_1.mp3', 
    () => { console.log("success"); }, // Success callback
    () => { console.log("failure"); },  // Error callback
    (progress) => { console.log(`Loading: ${progress * 100}%`); }  // While loading callback
    );
}

function setup() {
  createCanvas(100, 100);
  background(220);
}

function mousePressed() {
  player.play();
}

Expected Behavior

  • The whileLoading callback should print the loading progress percentage.
  • The callback should print "success" to the console when the sound is loaded.

Actual Behavior

  • The whileLoading callback isn't triggered, and loading progress isn't shown.
  • The callback isn't triggered, and "success" isn't printed.
@limzykenneth
Copy link
Member

@tmartinez88 this._decrementPreload() needs to be manually called when loading completes for preload() to work with loadSound(). See docs here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants