-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
198 lines (190 loc) · 4.8 KB
/
script.js
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
const play = document.getElementById("play");
const prev = document.getElementById("prev");
const next = document.getElementById("next");
const title = document.getElementById("title");
const artist = document.getElementById("artist");
const music = document.querySelector("audio");
const img = document.getElementById("img-main");
const vinyl = document.getElementById("img-sub");
const love = document.getElementById("love");
const mute = document.getElementById("un-mute");
const loop = document.getElementById("un-loop");
let isPlaying = false;
let songNumber = 0;
let isLooping = false;
let isLoving = false;
const playMusic = () => {
isPlaying = true;
music.play();
play.classList.replace("fa-play", "fa-pause");
img.classList.add("anime");
vinyl.classList.replace("vinyl-record-cancel", "vinyl-record");
};
const pauseMusic = () => {
isPlaying = false;
music.pause();
play.classList.replace("fa-pause", "fa-play");
img.classList.remove("anime");
vinyl.classList.replace("vinyl-record", "vinyl-record-cancel");
};
play.addEventListener("click", () => {
isPlaying ? pauseMusic() : playMusic();
});
const loadSong = (song) => {
title.textContent = song.title;
artist.style.fontStyle = "italic";
artist.textContent = "--- " + song.artist + " ---";
music.src = "Music/" + song.track + ".mp3";
img.src = "./public/artics/" + song.image + ".jpg";
};
next.addEventListener("click", () => {
songNumber++;
loadSong(songs[songNumber % songs.length]);
playMusic();
});
prev.addEventListener("click", () => {
--songNumber;
loadSong(songs[songNumber % songs.length]);
playMusic();
});
//--------------------------------------------------------------------------//
const inLove = () => {
isLoving = true;
love.src = "./public/heart.ico";
};
const outLove = () => {
isLoving = false;
love.src = "./public/unheart.ico";
};
love.addEventListener("click", () => {
isLoving ? outLove() : inLove();
});
//---------------------------------------------------------------------------//
const inLoop = () => {
isLooping = true;
music.loop = true;
loop.src = "./public/one_repeat.ico";
};
const outLoop = () => {
isLooping = false;
music.loop = false;
loop.src = "./public/un_repeat.ico";
};
loop.addEventListener("click", () => {
isLooping ? outLoop() : inLoop();
});
//---------------------------------------------------------------------------//
const songs = [
//1
{
title: "Comethru",
artist: "Jeremy Zucker",
image: "comethru",
track: "comethru"
},
//2
{
title: "Make you mine",
artist: "Public - The Band",
image: "make_you_mine",
track: "make you mine"
},
//3
{
title: "Hãy trao cho anh",
artist: "Sơn Tùng M-TP",
image: "hay_trao_cho_anh",
track: "hay trao cho anh"
},
//4
{
title: "Butterfly",
artist: "Nonstop",
image: "hay_trao_cho_anh",
track: "butterfly"
},
//5
{
title: "Ép duyên",
artist: "Long nón lá",
image: "hay_trao_cho_anh",
track: "ep duyen"
},
//6
{
title: "Legend never die",
artist: "Alan Walker",
image: "comethru",
track: "legends never die"
},
//7
{
title: "Lục dã Tiên Dung",
artist: "Various unknown",
image: "make_you_mine",
track: "luc da tien dung"
},
//8
{
title: "The style weeken",
artist: "Thailand sound",
image: "hay_trao_cho_anh",
track: "the style weeken"
},
//9
{
title: "Tình yêu màu hồng",
artist: "Văn Quý x Xám",
image: "hay_trao_cho_anh",
track: "tinh yeu mau hong"
},
//10
{
title: "Hẹn yêu",
artist: "Phan Yến Nhi x FreakD",
image: "hay_trao_cho_anh",
track: "hen yeu"
},
//11
{
title: "Hello friend",
artist: "Tiktok sound",
image: "hay_trao_cho_anh",
track: "hello friend"
},
//12
{
title: "Umbrella",
artist: "Ember Island",
image: "umbrella",
track: "umbrella"
},
//13
{
title: "Bên anh đêm nay remix",
artist: "DJ AM mix",
image: "ben_anh_dem_nay",
track: "ben anh dem nay"
},
//14
{
title: "I'm not her",
artist: "Clara Mae",
image: "i_am_not_her",
track: "i am not her"
},
//15
{
title: "Trouble is friend",
artist: "DJ Thái Hoàng",
image: "trouble_is_a_friend",
track: "trouble is a friend remix"
},
//16
{
title: "Weyrleader",
artist: "Maga",
image: "maga_weyrleader",
track: "maga weyrleader"
},
];