0% found this document useful (0 votes)
18 views

CPT-Program Code

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views

CPT-Program Code

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

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

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy