var currentsongstart = 0;
var manualInteraction = false;
songcassette = loadSound('thriller.mp3');
songcd = loadSound('heart.mp3');
songipod = loadSound('umberella.mp3');
songyoutube = loadSound('uptown.mp3');
songspotify = loadSound('lights.mp3');
musicnet = loadFont('musicnet.ttf');
gunplay = loadFont('gunplay.otf');
technology = loadFont('technology.ttf');
timeline = loadImage('timeline.png');
cnv = createCanvas(600, 550);
slider = createSlider(0, 1, 0.5, 0.01);
slider.position(10, height - 30);
btncassette = new imageButton("cassette.png", 150, 150);
btncassette.position(-20, height / 2 - 40);
btncassette.mousePressed(cassetteBtnPressed);
btncassette.mouseReleased(cassetteBtnReleased);
btncd = new imageButton("cd.png", 100, 100);
btncd.position(130, height / 2 - 10);
btncd.mousePressed(cdBtnPressed);
btncd.mouseReleased(cdBtnReleased);
btnipod = new imageButton("ipod.png", 100, 100);
btnipod.position(250, height / 2);
btnipod.mousePressed(ipodBtnPressed);
btnipod.mouseReleased(ipodBtnReleased);
btnyoutube = new imageButton("youtube.png", 100, 100);
btnyoutube.position(370, height / 2 - 20);
btnyoutube.mousePressed(youtubeBtnPressed);
btnyoutube.mouseReleased(youtubeBtnReleased);
btnspotify = new imageButton("spotify.png", 90, 90);
btnspotify.position(485, height / 2 - 5);
btnspotify.mousePressed(spotifyBtnPressed);
btnspotify.mouseReleased(spotifyBtnReleased);
btnplayauto = createButton('Play Automatically');
btnplayauto.position(430, height - 35);
btnplayauto.mousePressed(playSongsauto);
btnplaymanual = createButton('Play Manually');
btnplaymanual.position(430, height - 60);
btnplaymanual.mousePressed(playsongsmanual);
descriptionTxt = "Click the various listening devices to play a song that defined each era!";
currentlyPlayingTxt = "...";
songorder = [songcassette, songcd, songipod, songyoutube, songspotify];
var volume = slider.value();
songcassette.setVolume(volume);
songcd.setVolume(volume);
songipod.setVolume(volume);
songyoutube.setVolume(volume);
songspotify.setVolume(volume);
text(headerTxt, 300, 65);
text(descriptionTxt, 20, 95, width - 50);
if (songcassette.isPlaying() == true) {
currentlyPlayingTxt = 'Thriller by Michael Jackson';
} else if (songcd.isPlaying() == true) {
currentlyPlayingTxt = 'My Heart will Go on by Celine Dion';
} else if (songipod.isPlaying() == true) {
currentlyPlayingTxt = 'Umberella by Rihanna';
} else if (songyoutube.isPlaying() == true) {
currentlyPlayingTxt = 'Uptown Funk by Bruno Mars';
} else if (songspotify.isPlaying() == true) {
currentlyPlayingTxt = 'Blinding Lights by The Weeknd';
currentlyPlayingTxt = '..';
text(currentlyPlayingTxt, 20, height - 80, width - 50);
function playSongsauto() {
manualInteraction = false;
function playNextsong() {
if (manualInteraction == true) {
else if (currentsongstart < songorder.length) {
var currentSong = songorder[currentsongstart];
currentSong.onended(playNextsong);
function playsongsmanual() {
manualInteraction = true;
function stopallsongs() {
for(var i = 0; i < songorder.length; i = i + 1){
function cassetteBtnPressed() {
function cassetteBtnReleased() {
function cdBtnPressed() {
function cdBtnReleased() {
function ipodBtnPressed() {
function ipodBtnReleased() {
function youtubeBtnPressed() {
function youtubeBtnReleased() {
function spotifyBtnPressed() {
function spotifyBtnReleased() {