-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlrc-html5.html
60 lines (57 loc) · 1.34 KB
/
lrc-html5.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
<!DOCTYPE html>
<html>
<head>
<title>lrc-html5 | by SyiMyuZya</title>
<style type="text/css">
.fullwidth {
width: 60%;
}
</style>
</head>
<body>
<div>
<div>
<label>url:</label>
<input type="text" id="filename" value="music.mp3" />
<input type="button" value="load" onclick="loadFile(); return true" />
</div>
<div>
<audio id="player" controls=controls class="fullwidth">
</audio>
</div>
<div>
<input type="button" value="<" onclick="left(); return true;" />
<input type="button" value="tag" onclick="addTag(); return true;" />
<input type="button" value=">" onclick="right(); return true;" />
</div>
<div>
<textarea id="editor" rows="24" cols="80"></textarea>
</div>
</div>
<script>
filenameText = document.getElementById('filename');
player = document.getElementById('player');
editor = document.getElementById('editor');
function addTag() {
editor.value += formatTime(player.currentTime);
editor.scrollTop = editor.scrollHeight;
}
function formatTime(second) {
var zero = function(x) { return x<10?"0":"";}
var minute = second/60 | 0;
second -= minute*60;
return "["+zero(minute)+minute+":"+zero(second)+second.toFixed(2)+"]\n";
}
function left() {
player.currentTime -= 5;
}
function right() {
player.currentTime += 5;
}
function loadFile() {
player.src = filenameText.value.trim();
player.load();
}
</script>
</body>
</html>