Created
February 26, 2019 01:12
-
-
Save mrmemmo/47245b15c0af7bb06dfbd183e01d8ae7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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