Skip to content

Instantly share code, notes, and snippets.

@mrmemmo
Created February 26, 2019 01:12
Show Gist options
  • Save mrmemmo/47245b15c0af7bb06dfbd183e01d8ae7 to your computer and use it in GitHub Desktop.
Save mrmemmo/47245b15c0af7bb06dfbd183e01d8ae7 to your computer and use it in GitHub Desktop.
var song;
function setup() {
song = loadSound('assets/song.mp3');
createCanvas(720, 200);
background(255,0,0);
}
function mousePressed() {
if ( song.isPlaying() ) { // .isPlaying() returns a boolean
song.stop();
background(255,0,0);
} else {
song.play();
background(0,255,0);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment