Here’s another interesting finding. Can anyone crack this puzzle? If I place a sound in the setup function it will play when I hit the play button. However, if I navigate to the page through a link on my openprocessing.org homepage, then the sound won’t play. In that same scenario, if I place the sound in the draw function, though, it does play.
Here’s the code:
let bell;
function preload() {
soundFormats('mp3');
bell = loadSound('doorbell.mp3');
}
function setup() {
createCanvas(windowWidth, windowHeight);
bell.setVolume(0.5);
bell.play();
clickNotice();
}
function clickNotice() {
textSize(12);
textAlign(CENTER);
textFont("Helvetica");
text("If sound doesn't play, click the canvas or hit the refresh button to activate the sketch", width / 2, height / 2);
}