4/22/24, 9:39 PM AP PT CodePrint | Print Code
//List of songs that will play according to what is shown on screen.
//Code written by Skylar Ganir and Johanna Joseph
// The screen design was created by Johanna Joseph
var songList = [
"Good-Kid---Summer-(Official-Audio).mp3",
"Tone-Deaf-Girlfriend.mp3",
"Structure.mp3",
"From-the-Start.mp3",
"Death-By-Glamour.mp3",
"Friko---Get-Numb-To-It!-(Single-Version).mp3",
"The-Basement.mp3",
"Curses.mp3",
"Touch-Tone-Telephone.mp3",
"tripleS-(---------------)-'Rising'-Official-Audio.mp3"
];
//The var songIndex and songAudio will be used for updating the audio (refer to updateAudio fun
var songIndex;
var songAudio;
var albumImage;
//The data table was created by Johanna Joseph
//All songs and images belong to their owners. All song artists are in a column on the data tab
onEvent("button_shuffle", "click", function() {
stopSound();
//This reads the columns from the dataset
readRecords("Song playlist - PT task", {}, function(records) {
songIndex = randomNumber(0, records.length - 1);
var selectedSong = records[songIndex];
songAudio = selectedSong.songList;
setText("songName", selectedSong.songName);
setText("songArtist", selectedSong.songArtist);
setProperty("image_album", "image", selectedSong.albumImage);
});
updateScreen();
updateImages();
});
//These onEvents that executes the code based on the element ID
onEvent("pauseMusic", "click", function() {
stopSound();
});
onEvent("playMusic", "click", function() {
stopSound();
updateAudio();
});
onEvent("infoButton", "click", function() {
setScreen("infoscreen");
});
onEvent("buttonHome", "click", function() {
https://codeprint.org 1/2
4/22/24, 9:39 PM AP PT CodePrint | Print Code
51
setScreen("screen1");
52
});
53
54
//functions that are called for shuffling the playlist
55
function updateScreen() {
56
var songName = getColumn("Song playlist - PT task", "songName");
57
var songArtist = getColumn("Song playlist - PT task", "songArtist");
58
albumImage = getColumn("Song playlist - PT task", "albumImage");
59
setProperty("songName", "text", songName[0]);
60
setProperty("songArtist", "text", songArtist[0]);
61
}
62
63
function updateAudio() {
64
var audioIndex = songIndex;
65
songAudio = songList[audioIndex];
66
playSound(songList[audioIndex], false);
67
}
68
69
function updateImages() {
70
setProperty("image_album", "image", albumImage[0]);
71
}
PDF document made with CodePrint.org
https://codeprint.org 2/2