-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.html
More file actions
50 lines (47 loc) · 1.18 KB
/
index.html
File metadata and controls
50 lines (47 loc) · 1.18 KB
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
<html>
<head>
<title>VoiceRecorder.js Example</title>
</head>
<body>
<p id="info"></p>
<button id="start" onclick="startRecording();">Record</button>
<button id="stop" disabled="disabled" onclick="stopRecording();">Stop</button>
<script src="//code.jquery.com/jquery-3.2.1.min.js" integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=" crossorigin="anonymous"></script>
<script src="VoiceRecorder.js"></script>
<script>
var recorder;
// Page loaded - Create Recorder
document.addEventListener("DOMContentLoaded", function()
{
recorder = new VoiceRecorder();
});
// Start recording
function startRecording()
{
recorder.start(function(status)
{
if(status == "OK")
{
$("#start").attr("disabled", "disabled");
$("#stop").removeAttr("disabled");
}
});
}
// Stop recording
function stopRecording()
{
recorder.get(function(blob)
{
$("#stop").attr("disabled", "disabled");
reader = new FileReader();
reader.onload = function()
{
window.open(this.result.replace("data:;", "data:audio/wav;"));
}
reader.readAsDataURL(blob);
$("#start").removeAttr("disabled");
}).stop();
}
</script>
</body>
</html>