-
Notifications
You must be signed in to change notification settings - Fork 142
/
example-1.html
86 lines (75 loc) · 2.47 KB
/
example-1.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<title>Recorder Example</title>
<link rel="stylesheet" type="text/css" href="example.css" />
</head>
<body>
<script type="text/javascript" src="../recorder.js"></script>
<script>
function timecode(ms) {
var hms = {
h: Math.floor(ms/(60*60*1000)),
m: Math.floor((ms/60000) % 60),
s: Math.floor((ms/1000) % 60)
};
var tc = []; // Timecode array to be joined with '.'
if (hms.h > 0) {
tc.push(hms.h);
}
tc.push((hms.m < 10 && hms.h > 0 ? "0" + hms.m : hms.m));
tc.push((hms.s < 10 ? "0" + hms.s : hms.s));
return tc.join(':');
}
Recorder.initialize({
swfSrc: "../recorder.swf"
});
function record(){
Recorder.record({
start: function(){
//alert("recording starts now. press stop when youre done. and then play or upload if you want.");
},
progress: function(milliseconds){
document.getElementById("time").innerHTML = timecode(milliseconds);
}
});
}
function play(){
Recorder.stop();
Recorder.play({
progress: function(milliseconds){
document.getElementById("time").innerHTML = timecode(milliseconds);
}
});
}
function stop(){
Recorder.stop();
}
function upload(){
Recorder.upload({
url: "https://example.com/upload",
audioParam: "your_file",
success: function(){
alert("your file was uploaded!");
}
});
}
</script>
<div id="wrapper">
<h1><a href="http://github.com/jwagener/recorder">Recorder Example</a></h1>
<p>
This is a very basic example for the Recorder.js.
Checkout <a href="http://github.com/jwagener/recorder">GitHub</a> for details and have a look at the source for this file.
Start by clicking record:
</p>
<div>
<a href="javascript:record()" id="record" >Record</a>
<a href="javascript:play()" id="play" >Play</a>
<a href="javascript:stop()" id="stop" >Stop</a>
<a href="javascript:upload()" id="upload" >Upload (faked)</a>
</div>
<span id="time">0:00</span>
</div>
</body>
</html>