Question about openprocessing.org functionality

Hello all,

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.

In this thread, someone pointed out that the you need to direct the browser to the canvas. I’m wondering why this particular nuance occurs though, depending on how you navigate to the page. Does anyone have any insight? (Thanks!)

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);
}
1 Like

I just assume that the play button treats setup differently than the call via the browser. That’s not really an explanation.

Just out of curiosity: did you program a Moebius band?

Thanks :slight_smile: And no, I’m afraid I didn’t. That nickname is from forever ago. I liked some of the connotations of the infinity symbol.

1 Like

Hey There!

Just to add,
I believe by default as well Google Chrome (if Chrome was used) doesn’t play sounds now if a page is entered.

Tricky. This sounds like it might be worth documenting in a p5.js issue, if there isn’t one already.

With the Google Chrome thing it a standard for all platforms. I made a HTML game 2 months back and sounds within the game to play had to have the button clicked they would not play by default.