xxxxxxxxxx
30
let song;
let button;
function setup() {
createCanvas(400, 400);
song = loadSound('Kid_Cudi_Day_N_Nite_Ringtone_(by Fringster.com).mp3',loaded);
button = createButton('play');
button.mousePressed(togglePlaying);
background(51);
}
function togglePlaying(){
if (!song.isPlaying()){
song.play();
song.setVolume(0.3);
button.html('pause');
} else {
song.pause();
button.html('play');
}
}
function loaded() {
console.log(loaded);
}
function draw() {
background(220);
}