-
Notifications
You must be signed in to change notification settings - Fork 1
/
music.html
142 lines (124 loc) · 3.13 KB
/
music.html
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
<html>
<head>
<link href="https://fonts.googleapis.com/css?family=Maven+Pro&display=swap" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" />
</head>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<h1 style="color:purple"><i class="fa fa-music" aria-hidden="true"></i> Dil Bechara Album<i class="fa fa-music" aria-hidden="true"></i> </h1>
<main>
<div class="a song">a</div>
<div class="b song">b</div>
<div class="c song">c</div>
<div class="d song">d</div>
<div class="e song">e</div>
<div class="f song">f</div>
<div class="g song">g</div>
<div class="h song">h</div>
<div class="i song">i</div>
</main>
<script>
var divlength=document.querySelectorAll('.song').length;
for( var i=0;i<divlength;i++)
{
var demo=document.querySelectorAll('.song')[i].addEventListener('click',playsong);/*querySelector help to take the cursor to the song and addEventListner acess it querySelectorAll to show all the class in the div to acessit and array element to acess it and get the value to acess it */
var demo = document.querySelectorAll('.song')[i].addEventListener('dblclick',pausesong);
}
var song1= new Audio();
song1.src="music/Dil-Bechara-Ringtone.mp3";
var song2= new Audio();
song2.src="music/taare-ginn.mp3";
var song3= new Audio();
song3.src="music/Kulkhe-Jeene-Ka-Ringtone.mp3";
var song4= new Audio();
song4.src="music/Main-Jaanu-Ki-Ringtone.mp3";
var song5= new Audio();
song5.src="music/Main-Thumhara-Ringtone.mp3";
var song6= new Audio();
song6.src="music/Mera-Naam-Kizzie-Ringtone.mp3";
var song7= new Audio();
song7.src="music/Kar-Band-Sabhi-Gadiya-Ringtone-1.mp3";
var song8= new Audio();
song8.src="music/Sushants-Dialogue.mp3";
var song9= new Audio();
song9.src="music/Kar-Band-Gadiya-BGM-Humming-Tone-.mp3";
function playsong()
{
//console.log(this);
//console.log(this.innerHTML); to show all the song in the particular poistion
var songID=this.innerHTML;
console.log(songID);
switch(songID)
{
case "a":
song1.play();
break;
case "b":
song2.play();
break;
case "c":
song3.play();
break;
case "d":
song4.play();
break;
case "e":
song5.play();
break;
case "f":
song6.play();
break;
case "g":
song7.play();
break;
case "h":
song8.play();
break;
case "i":
song9.play();
break;
default:
console.log("wrong input");
break;
}
}
function pausesong(){
var songId = this.innerHTML;
console.log(songId);
switch (songId) {
case "a":
song1.pause();
break;
case "b":
song2.pause();
break;
case "c":
song3.pause();
break;
case "d":
song4.pause();
break;
case "e":
song5.pause();
break;
case "f":
song6.pause();
break;
case "g":
song7.pause();
break;
case "h":
song8.pause();
break;
case "i":
song9.pause();
break;
default:
console.log("wrong input");
break;
}
}
</script>
</body>
</html>