CPT-Program Code
CPT-Program Code
//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();
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
}
https://codeprint.org 2/2