-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathJukebox.js
More file actions
228 lines (198 loc) · 6.37 KB
/
Jukebox.js
File metadata and controls
228 lines (198 loc) · 6.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
var vid = document.getElementById("bgvid");
//Jukebox HTML elements stored in variables
var playIcon = document.getElementById("play")
var pauseIcon = document.getElementById("pause")
var stopIcon = document.getElementById("stop")
var nextIcon = document.getElementById("next")
var prevIcon = document.getElementById("previous")
var newSongButton = document.querySelector("#newsong")
var lBrown = document.getElementById("LBrown")
var mfDoom = document.getElementById("MFDoom")
var kidCudi = document.getElementById("KidCudi")
var Gambino = document.getElementById("Childish")
var Baccono = document.getElementById("Guns")
var Systeme = document.getElementById("Magic")
var titleSpot = document.querySelector("#ShowMusicTitle")
var artistSpot = document.querySelector("#ShowArtist")
// counter
var index = [0];
var songs = [
new Audio("Music/11 Lady Brown feat. Cise Starr.mp3"),
new Audio("Music/mfdoom-vomitspit.mp3"),
new Audio("Music/Kid Cudi and Crookers - Day 'n' Night.mp3"),
new Audio("Music/Do Ya Like.mp3"),
new Audio("Music/Baccano! - Gun's and Roses.mp3"),
new Audio("Music/Un Gaou A Oran.mp3")
]
//instantiation: jukebox object created, songs pushed into jukebox array
var jukebox = new Jukebox(songs)
var titles = [
"Title: Lady Brown ft. Cise Starr",
"Title: Vomitspit",
"Title: Day N Night",
"Title: Do Ya Like",
"Title: Gun's and Roses",
"Title: Un Gaou A Oran"
]
var artists = [
"Artist: Nujabes",
"Artist: MF Doom",
"Artist: Kid Cudi",
"Artist: Childish Gambino",
"Artist: Baccano",
"Artist: Magic Systeme"
]
//Jukebox object constructor function: Jukebox object structure & methods
function Jukebox() {
this.songs = songs
}
//setting the button methods
Jukebox.prototype.play = function() {
this.songs[index].play()
}
Jukebox.prototype.pause = function() {
this.songs[index].pause()
}
Jukebox.prototype.stop = function() {
this.songs[index].pause()
this.songs[index].currentTime = 0
}
Jukebox.prototype.back = function() {
this.songs[index].pause()
this.songs[index].currentTime = 0
index--
if (index < 0) {
index = this.songs.length -1
}
this.songs[index].play()
}
Jukebox.prototype.forward = function () {
this.songs[index].pause()
this.songs[index].currentTime = 0
index++
this.songs[index]
if (index === this.songs.length) {
index = [0]
}
this.songs[index].play()
}
// button event listeners
playIcon.addEventListener("click", function(event){
event.preventDefault();
ShowMusicTitle.innerHTML = titles[index];
ShowArtist.innerHTML = artists[index];
jukebox.play();
playIcon.style.color = "#FF1493";
pauseIcon.style.color = "#000000";
stopIcon.style.color = "#000000";
prevIcon.style.color = "#000000";
nextIcon.style.color = "#000000";
})
pauseIcon.addEventListener("click", function(event){
event.preventDefault()
jukebox.pause()
ShowMusicTitle.innerHTML = titles[index]
ShowArtist.innerHTML = artists[index]
pauseIcon.style.color = "#FF1493";
playIcon.style.color = "#000000";
stopIcon.style.color = "#000000";
nextIcon.style.color = "#000000";
prevIcon.style.color= "#000000";
})
stopIcon.addEventListener("click", function(event) {
event.preventDefault()
jukebox.stop()
stopIcon.style.color = "#FF1493";
playIcon.style.color = "#000000";
pauseIcon.style.color = "#000000";
nextIcon.style.color= "#000000";
prevIcon.style.color= "#000000";
})
nextIcon.addEventListener("click", function(event){
event.preventDefault()
jukebox.forward()
ShowMusicTitle.innerHTML = titles[index]
ShowArtist.innerHTML = artists[index]
nextIcon.style.color="#FF1493"
prevIcon.style.color="#000000"
playIcon.style.color = "#000000";
pauseIcon.style.color = "#000000";
stopIcon.style.color = "#000000";
})
prevIcon.addEventListener("click", function(event){
event.preventDefault()
jukebox.back()
ShowMusicTitle.innerHTML = titles[index]
ShowArtist.innerHTML = artists[index]
prevIcon.style.color="#FF1493";
nextIcon.style.color="#000000";
playIcon.style.color = "#000000";
pauseIcon.style.color = "#000000";
stopIcon.style.color = "#000000";
})
newSongButton.addEventListener("click", function(event) {
event.preventDefault()
var songField = document.querySelector("#songfield")
var newSong = new Audio(songField.value)
var titleField = document.querySelector("#titlefield")
var newTitle = "Title: " + titleField.value
var artistField = document.querySelector("#artistfield")
var newArtist = "Artist: " + artistField.value
songs.push(newSong)
titles.push(newTitle)
artists.push(newArtist)
})
lBrown.addEventListener("click", function(event){
event.preventDefault()
var lbrownmusic = new Audio("Music/11 Lady Brown feat. Cise Starr.mp3")
var lbrownTitle = "Title: " + "Lady Brown"
var lbrownArtist= "Artist: " + "Nujabes"
songs.push(lbrownmusic)
titles.push(lbrownTitle)
artists.push(lbrownArtist)
})
mfDoom.addEventListener("click", function(event){
event.preventDefault()
var mfdoomusic = new Audio("Music/mfdoom-vomitspit.mp3")
var mfdoomTitle = "Title: " + "Vomitspit"
var mfdoomArtist = "Artist: " + "MF Doom"
songs.push(mfdoomusic)
titles.push(mfdoomTitle)
artists.push(mfdoomArtist)
})
kidCudi.addEventListener("click", function(event){
event.preventDefault()
var DayNight = new Audio("Music/Kid Cudi and Crookers - Day 'n' Night.mp3")
var DayNightTitle = "Title: " + "Day /& Night"
var DayNightArtist = "Artist: " + "Kid Cudi"
songs.push(DayNight)
titles.push(DayNightTitle)
artists.push(DayNightArtist)
})
Gambino.addEventListener("click", function(event){
event.preventDefault()
var childish = new Audio("Music/Do Ya Like.mp3")
var childishTitle = "Title: " + "Do Ya Like"
var childishArtist = "Artist: " + "Childish Gambino"
songs.push(childish)
titles.push(childishTitle)
artists.push(childishArtist)
})
Baccono.addEventListener("click", function(event){
event.preventDefault()
var gbaccano = new Audio("Music/Baccano! - Gun's and Roses.mp3")
var baccanoTitle = "Title: " + "Guns & Roses"
var baccanoArtist = "Artist: " + "Baccono"
songs.push(gbaccano)
titles.push(baccanoTitle)
artists.push(baccanoArtist)
})
Systeme.addEventListener("click", function(event){
event.preventDefault()
var mSysteme = new Audio("Music/Un Gaou A Oran.mp3")
var systemeTitle = "Title: " + "Guns & Roses"
var systemeArtist = "Artist: " + "Baccano"
songs.push(mSysteme)
titles.push(systemeTitle)
artists.push(systemeArtist)
})