forked from vocaroo/simple-audio-recorder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
39 lines (33 loc) · 1011 Bytes
/
index.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
<!doctype html>
<html>
<head>
<script type="text/javascript" src="../../dist/audiorecorder.js"></script>
</head>
<body>
<script>
AudioRecorder.preload("../../dist/mp3worker.js");
let recorder = new AudioRecorder();
function start() {
recorder.start().then(() => {
console.log("Recording started...");
}).catch(error => {
console.log("Recording start error", error);
});
}
function stop() {
recorder.stop().then(mp3Blob => {
console.log("Recording stopped...");
const newAudio = document.createElement("audio");
newAudio.src = URL.createObjectURL(mp3Blob);
newAudio.controls = true;
document.getElementById("id_content").append(newAudio);
}).catch(error => {
console.log("Recording stop error", error);
});
}
</script>
<button id="id_start" onclick="start()">start recording</button>
<button id="id_stop" onclick="stop()">stop recording</button>
<div id="id_content"></div>
</body>
</html>