-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathexample.html
59 lines (54 loc) · 1.33 KB
/
example.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
<!DOCTYPE html>
<html xmlns='http://www.w3.org/1999/xhtml'>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8' />
<title></title>
</head>
<body>
<div>
<audio controls autoplay></audio>
<input onclick='start()' type='button' value='录音' />
<input onclick='stop()' type='button' value='停止' />
<input onclick='getURL()' type='button' value='显示' />
<input onclick='upload()' type='button' value='提交' />
<a href="javascript:;" id="download">下载</a>
</div>
<script type='text/javascript' src='mrecorder.js'></script>
<script>
function start(){
var rec = new mRecorder({
callback:function(){
rec.start();
window.rec = rec;
}
});
}
function stop() {
rec.stop();
}
function getURL() {
document.querySelector('audio').src = rec.getURL();
document.getElementById('download').href = rec.getURL();
}
function upload() {
rec.upload('upload.php', function (state, e) {
switch (state) {
case 'uploading':
//var percentComplete = Math.round(e.loaded * 100 / e.total) + '%';
break;
case 'ok':
//alert(e.target.responseText);
alert('上传成功');
break;
case 'error':
alert('上传失败');
break;
case 'cancel':
alert('上传被取消');
break;
}
});
}
</script>
</body>
</html>