-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.php
195 lines (153 loc) · 5.85 KB
/
index.php
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
<!DOCTYPE html>
<html>
<head>
<style type="text/css">
div#container {
width: 100%;
height: 100%;
}
div#header {
background-color: #99bbbb;
text-align: center;
}
div#find {
height: auto;
width: 100%;
display: inline-block;
text-align: center;
}
div#content {
height: 70%;
width: 100%;
display: inline-block;
text-align: center;
}
i#dl {
color: #6078ff;
}
a#link {
color: white;
text-decoration: none;
}
html, body {
height: 100%;
width: 100%;
margin: 0;
padding: 0;
}
h1 {
margin-bottom: 0;
}
h2 {
margin-bottom: 0;
font-size: 14px;
}
ul {
margin: 0;
}
li {
list-style: none;
}
</style>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.1/css/font-awesome.min.css">
</head>
<body>
<div id="container">
<div id="header">
<h1>MUSIC PLAYER</h1>
</div>
<div id="find">
<ul>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>Music</title>
</head>
<body>
</body>
</ul>
<audio id="audio1" style="width:60%" controls>Canvas not supported</audio>
</div>
<section>
<link rel="stylesheet" type="text/css" href="table.css">
<!--for demo wrap-->
<div class="tbl-header" id="content">
<table align="center">
<tr align="center">
<th><img src="/icons/blank.gif" alt="[ICO]"></th>
<th>Name</th>
<th>Time</th>
<th>Artist</th>
<th>Album</th>
<td> </td>
<td> </td>
</tr>
</table>
</div>
<div class="tbl-content">
<table cellpadding="0" cellspacing="0" border="0" align="center">
<tbody align="center">
<?php
require_once('getID3/getid3/getid3.php');
// Initialize getID3 engine
$getID3 = new getID3;
$DirectoryToScan = 'music'; // change to whatever directory you want to scan
$dir = opendir($DirectoryToScan);
$num = 0;
while (($file = readdir($dir)) !== false) {
$FullFileName = realpath($DirectoryToScan.'/'.$file);
if ((substr($file, 0, 1) != '.') && is_file($FullFileName)) {
set_time_limit(30);
$ThisFileInfo = $getID3->analyze($FullFileName);
getid3_lib::CopyTagsToComments($ThisFileInfo);
$len=strlen($file);
$name=substr($file,0,$len-4);
// output desired information in whatever format you want
echo '<tr>';
echo '<td><i class="fa fa-music fa-lg" aria-hidden="false"></i></td>';
echo '<td>' .htmlentities(!empty($ThisFileInfo['comments_html']['title']) ? implode( $ThisFileInfo['comments_html']['title']) : chr(160)).'</td>';
echo '<td align="left">'.htmlentities(!empty($ThisFileInfo['playtime_string']) ? $ThisFileInfo['playtime_string'] : chr(160)).'</td>';
echo '<td>' .htmlentities(!empty($ThisFileInfo['comments_html']['artist']) ? implode( $ThisFileInfo['comments_html']['artist']) : chr(160)).'</td>';
echo '<td>' .htmlentities(!empty($ThisFileInfo['comments_html']['album']) ? implode( $ThisFileInfo['comments_html']['album']) :chr(160)).'</td>';
echo '<td> <button class="btn" id=\''.$file.'\' name='.$num.' onclick="playAudio(\'audio1\' , this.id);"> <i class=\'fa fa-play fa-lg\' aria-hidden=\'true\'></i> </button>';
echo '<a class="link" href= "music/'. $file .'" download=\''. $file .'\'>';
echo '<i id="dl" class="fa fa-download fa-lg" aria-hidden="true"></i> </a></td>';
echo '<td> </td>';
echo '</tr>';
$num++;
}
}
?>
</table>
<script type="text/javascript">
function playAudio(audioElm, clicked_id) {
var audioElm = document.getElementById('audio1');
audioElm.src = "music/" + document.getElementById(clicked_id).id;
audioElm.play();
}
var audioElm = document.getElementById('audio1');
function nextMusic(){
var audioElm = document.getElementById('audio1');
var musicPath=audioElm.src;
var index= musicPath.lastIndexOf("/");
var musicID=musicPath.substr(index+1);
musicID=musicID.replace(/%20/g, " ");
var bn=document.getElementById(musicID);
var nameNext= parseInt(bn.name) +1;
//the return value of getElementsByName is Array.
var bnNext=document.getElementsByName(nameNext.toString());
audioElm.src = "music/" + bnNext[0].id;
audioElm.play();
}
audioElm.onended = function(){ nextMusic();};
// '.tbl-content' consumed little space for vertical scrollbar, scrollbar width depend on browser/os/platfrom. Here calculate the scollbar width .
$(window).on("load resize ", function () {
var scrollWidth = $('.tbl-content').width() - $('.tbl-content table').width();
$('.tbl-header').css({
'padding-right': scrollWidth
});
}).resize();
</script>
</div>
</section>
</body>
</html>