diff options
Diffstat (limited to 'app.js')
-rw-r--r-- | app.js | 8 |
1 files changed, 6 insertions, 2 deletions
@@ -5,6 +5,7 @@ | |||
5 | */ | 5 | */ |
6 | 6 | ||
7 | const errorContainer = document.querySelector("#error"); | 7 | const errorContainer = document.querySelector("#error"); |
8 | const recordingIndicator = document.querySelector("#recording-indicator"); | ||
8 | const recordBtn = document.querySelector("#record"); | 9 | const recordBtn = document.querySelector("#record"); |
9 | const autoplayCheckbox = document.querySelector("#autoplay"); | 10 | const autoplayCheckbox = document.querySelector("#autoplay"); |
10 | const clearBtn = document.querySelector("#clear"); | 11 | const 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); |