-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcyberplay.html
91 lines (80 loc) · 2.08 KB
/
cyberplay.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
<!DOCTYPE html>
<html>
<head>
<title>CyberPlay</title>
</head>
<style type="text/css">
body{
font-family: sans-serif;
margin:0;
padding: 0;
background: #F6F7F8;
}
#footer{
width: 100%;
height:50px;
background: #7d53de;
}
.footer_title{
text-align: center;
color: white;
font-size: 25px;
position: relative;
top:10px;
left:10px;
}
#playlist li:hover{
cursor: pointer;
}
</style>
<body>
<div id="footer">
<span class="footer_title">CyberPlay</span>
</div>
<input type="file" webkitdirectory directory multiple mozdirectory id="files" name="file" />
<br>
<audio id="player" controls></audio>
<button onclick="nextSong()" ><</button>
<button onclick="prevSong()" >></button>
<div>
<ol id="playlist">
</ol>
</div>
</body>
<script>
var j=0; //j is the index of the song played
var playlist=[]; //playlist contains the files uploaded
var player= document.getElementById('player')
var playlist_ol=document.getElementById('playlist');
function nextSong(){
}
function handleFileSelect(evt) {
// Reset progress indicator on new file selection.
playlist=[];
j=0;
playlist_ol.innerHTML="";
for(var i=0;i<evt.target.files.length;i++){
if(evt.target.files[i].size>4095 &&
(evt.target.files[i].name.indexOf('mp3')!=-1 || evt.target.files[i].name.indexOf('ogg')!=-1)) {
var li=document.createElement('li');
li.url=window.URL.createObjectURL(evt.target.files[i]);
li.onclick=function(e){
player.setAttribute('src',e.target.url);
player.play();
}
li.innerHTML=evt.target.files[i].name;
playlist_ol.appendChild(li);
playlist.push(evt.target.files[i]);
}
}
player.setAttribute('src',window.URL.createObjectURL(playlist[j++]));
player.play();
player.onended=function(){
player.setAttribute('src',window.URL.createObjectURL(playlist[j++]));
player.play();
}
document.getElementById('files').style('display','none');
}
document.getElementById('files').addEventListener('change', handleFileSelect, false);
</script>
</html>