-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.html
More file actions
140 lines (113 loc) · 4.15 KB
/
index.html
File metadata and controls
140 lines (113 loc) · 4.15 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
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Audio Player</title>
<link rel="stylesheet" type="text/css" href="css/style.css">
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script>
$(document).ready(function() {
i=0;
var playListCount = $('.playsong').size();
nowPlaying = document.getElementsByClassName('playsong');
//loads all songs into a variable
nowPlaying[i].load();
$('.play').on('click', function() {
nowPlaying[i].play();
callMeta();
});
$('.stop').on('click', function() {
nowPlaying[i].pause();
callMeta();
});
$('.next').on('click', function() {
if (i < playListCount -1) {
$.each($('audio.playsong'), function() {
this.pause();
});
++i;
// nowPlaying = audioArray[i];
nowPlaying[i].load();
nowPlaying[i].play();
callMeta();
}
});
$('.prev').on('click', function() {
if (i >= playListCount -7) { // -4 because there are 5 tracks and it starts counting at 0
$.each($('audio.playsong'), function() {
this.pause();
});
--i;
nowPlaying[i].load();
nowPlaying[i].play();
callMeta();
}
});
function callMeta() {
var trackTitle = $(nowPlaying[i]).attr('data-songtitle');
$('.songtitle').html(trackTitle);
var trackArtist = $(nowPlaying[i]).attr('data-songartist');
$('.songartist').html(trackArtist);
var albumArt = $(nowPlaying[i]).attr('data-albumart');
$('img.albumart').attr('src', albumArt);
}
})
</script>
</head>
<body>
<h1>HTML5 Audio Player</h1>
<div id='button_position'>
<div class="play">
<form>
<input type='button' value='Play' class='button'>
</form><br>
</div>
<div class="stop">
<form>
<input type='button' value='Stop' class='button'>
</form><br>
</div>
<div class="next">
<form>
<input type='button' value='Next' class='button'>
</form><br>
</div>
<div class="prev">
<form>
<input type='button' value='Prev' class='button'>
</form><br>
</div>
</div>
<audio class="playsong" data-songtitle="The Only Place" data-songartist="Best Coast" data-albumart="img/The+Only+Place++HQ.png" src="song/Best Coast - The Only Place.mp3"/>
Your browser does not support the HTML audio tag!
</audio>
<audio class="playsong" data-songtitle="Black Hills" data-songartist="Gardens & Villa" data-albumart="img/Gardens++Villa+cover.jpg" src="song/Gardens & Villa - Black Hills.mp3"/>
Your browser does not support the HTML audio tag!
</audio>
<audio class="playsong" data-songtitle="Before The Bridge" data-songartist="Future Islands" data-albumart="img/Future+Islands.jpg" src="song/Future Islands - Before the Bridge.mp3"/>
Your browser does not support the HTML audio tag!
</audio>
<audio class="playsong" data-songtitle="Stay Useless" data-songartist="Cloud Nothings" data-albumart="img/Attack+on+Memory.png" src="song/Cloud Nothings - Stay Useless.mp3"/>
Your browser does not support the HTML audio tag!
</audio>
<audio class="playsong" data-songtitle="2080" data-songartist="Yeasayer" data-albumart="img/All+Hour+Cymbals+Picture+2.png" src="song/Yeasayer - 2080.mp3"/>
Your browser does not support the HTML audio tag!
</audio>
<audio class="playsong" data-songtitle="Know Me" data-songartist="Frankie Rose" data-albumart="img/Interstellar.png" src="song/Frankie Rose - Know Me.mp3"/>
Your browser does not support the HTML audio tag!
</audio>
<audio class="playsong" data-songtitle="Hawaii" data-songartist="Blackbird Blackbird" data-albumart="img/Summer+Heart+BLACKBIRD.png" src="song/Blackbird Blackbird - Hawaii.mp3"/>
Your browser does not support the HTML audio tag!
</audio>
<audio class="playsong" data-songtitle="Twins" data-songartist="Gem Club" data-albumart="img/Breakers++cover.jpg" src="song/Gem Club - Twins.mp3"/>
Your browser does not support the HTML audio tag!
</audio>
<div id='info'>
<div class='songtitle'>Song Title</div>
<div class='songartist'>Artist</div>
<div id='art_position'>
<img class='albumart' src='img/needle.jpg' height='340px' width='300px'></img>
</div>
</div>
</body>
</html>