Skip to content

loadSound Callbacks Not Triggering #26

Open
@SableRaf

Description

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.

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions