aboutsummaryrefslogtreecommitdiff
path: root/app.js
diff options
context:
space:
mode:
Diffstat (limited to 'app.js')
-rw-r--r--app.js8
1 files changed, 6 insertions, 2 deletions
diff --git a/app.js b/app.js
index 345c613..5095e20 100644
--- a/app.js
+++ b/app.js
@@ -5,6 +5,7 @@
5 */ 5 */
6 6
7const errorContainer = document.querySelector("#error"); 7const errorContainer = document.querySelector("#error");
8const recordingIndicator = document.querySelector("#recording-indicator");
8const recordBtn = document.querySelector("#record"); 9const recordBtn = document.querySelector("#record");
9const autoplayCheckbox = document.querySelector("#autoplay"); 10const autoplayCheckbox = document.querySelector("#autoplay");
10const clearBtn = document.querySelector("#clear"); 11const clearBtn = document.querySelector("#clear");
@@ -28,13 +29,16 @@ function onGetDeviceSuccess(stream) {
28 const mediaRecorder = new MediaRecorder(stream); 29 const mediaRecorder = new MediaRecorder(stream);
29 let recordingChunks = []; 30 let recordingChunks = [];
30 31
31 // TODO: add some recording indicator (red bullet) when recording
32
33 mediaRecorder.addEventListener("dataavailable", event => { 32 mediaRecorder.addEventListener("dataavailable", event => {
34 recordingChunks.push(event.data); 33 recordingChunks.push(event.data);
35 }); 34 });
36 35
36 mediaRecorder.addEventListener("start", _event => {
37 recordingIndicator.classList.add("active");
38 });
39
37 mediaRecorder.addEventListener("stop", _event => { 40 mediaRecorder.addEventListener("stop", _event => {
41 recordingIndicator.classList.remove("active");
38 const blob = new Blob(recordingChunks, { type: mediaRecorder.mimeType }); 42 const blob = new Blob(recordingChunks, { type: mediaRecorder.mimeType });
39 recordingChunks = []; 43 recordingChunks = [];
40 const audioElement = audioElementForBlob(blob); 44 const audioElement = audioElementForBlob(blob);