forked from IAmrinderSingh/MusicWebsite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmysheet.js
130 lines (121 loc) · 2.85 KB
/
mysheet.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
const music = document.querySelector("audio");
const img = document.querySelector("img");
const play = document.getElementById("play");
const artist = document.getElementById("artist");
const title = document.getElementById("title");
const prev = document.getElementById("prev");
const next = document.getElementById("next");
const songs = [
{
name: "thenightwemeet",
title: "the night we met",
artist: "lord huron",
},
{
name: "backtoyou",
title: "back to you",
artist: "selena gomez",
},
{
name: "rasputin",
title: "Rasputine",
artist: "boney.m",
},
{
name: "kebanu",
title: "Ke banu Duniya da",
artist: "Gurdas man & diljit",
},
{
name: "thuglife",
title: "Thug Life",
artist: "Diljit dosanjh",
},
{
name: "goat",
title: "G.O.A.T",
artist: "Diljit dosanjh",
},
{
name: "plazo2",
title: "PALAZZO 2",
artist: "Shivjot",
},
{
name: "timetable",
title: "Time Table",
artist: "Kulwinder Billa",
},
{
name: "udarrian",
title: "udaarian",
artist: "Satinder Sartaj",
},
{
name: "khabbi",
title: "Khabbi Seat",
artist: "Ammy Virk",
},
{
name: "raule",
title: "Raule",
artist: "Jassa Dhillon",
},
{
name: "ikko",
title: "Ikko Mikke",
artist: "Satinder Sartaj",
},
{
name: "born",
title: "Born to Shine",
artist: "Diljit dosanjh",
},
]
let isplaying = false;
const playmusic = () => {
isplaying = true;
music.play();
play.classList.replace("fa-play", "fa-pause");
img.classList.add("anime");
};
const pausemusic = () => {
isplaying = false;
music.pause();
play.classList.replace("fa-pause", "fa-play");
img.classList.remove("anime");
};
play.addEventListener("click", () => {
if (isplaying) {
pausemusic();
}
else {
playmusic();
}
});
const loadsong = (songs) => {
title.textContent = songs.title;
artist.textContent = songs.artist;
music.src ="songs/"+ songs.name + ".m4a";
if (("backtoyou" == songs.name) || ("thuglife" == songs.name) || ("ikko" == songs.name) || ("khabbi" == songs.name) || ("rasputin" == songs.name))
{
img.src = "images/" + songs.name + ".jpeg"
}
else
{
img.src = "images/" + songs.name + ".jpg"
}
};
songIndex = 0;
const nextsong = () => {
songIndex = (songIndex + 1) % songs.length;
loadsong(songs[songIndex]);
playmusic();
};
const prevsong = () => {
songIndex = (songIndex - 1 + songs.length) % songs.length;
loadsong(songs[songIndex]);
playmusic();
};
next.addEventListener("click", nextsong);
prev.addEventListener("click", prevsong);