-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
110 lines (78 loc) · 2.21 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
const heading = document.getElementById('heading');
const subHeading = document.getElementById('sub-heading');
const songImg = document.getElementById('song-img');
const audio = document.getElementById('audio');
const prev = document.getElementById('prev');
const next = document.getElementById('next');
const play = document.getElementById('play');
play.onclick = function () {
if (audio.paused) {
audio.play();
play.src = "pause.png";
}
else {
audio.pause();
play.src = "play.png";
}
}
audio.addEventListener('play', () => {
play.src = "pause.png";
});
audio.addEventListener('pause', () => {
play.src = "play.png";
});
var img = new Array(
"pic2.jpg",
"pic1.jpg",
"pic3.jpg",
"pic4.jpg"
);
var music = new Array(
"audio1.mp3",
"audio2.mp3",
"audio3.mp3",
"audio4.mp3"
);
var song = new Array(
"Dil Ko Karaar Aaya",
"Mann Mera",
"Thoda Thoda Pyaar",
"Pal"
);
var artist = new Array(
"Neha Kakkar & Yasser Desai",
"Gajendra Verma",
"Stebin Ben & Nilesh Ahuja",
"Arijit Singh &Shreya Ghoshal"
);
let i = 0;
next.onclick = function () {
if (i <= 3) {
if (i == 3) {
i = -1;
}
document.body.style.backgroundImage = 'linear-gradient(rgba(35, 43, 56, 0.9), rgba(35, 43, 56, 0.9)), url("' + img[i + 1] + '")';
songImg.src = img[i + 1];
audio.src = music[i + 1];
audio.play();
play.src = "pause.png";
heading.innerHTML = song[i + 1];
subHeading.innerHTML = artist[i + 1];
i++;
}
}
prev.onclick = function () {
if (i >= 0) {
if (i == 0) {
i = 4;
}
document.body.style.backgroundImage = 'linear-gradient(rgba(35, 43, 56, 0.9), rgba(35, 43, 56, 0.9)), url("' + img[i - 1] + '")';
songImg.src = img[i - 1];
audio.src = music[i - 1];
audio.play();
play.src = "pause.png";
heading.innerHTML = song[i - 1];
subHeading.innerHTML = artist[i - 1];
i--;
}
}