Basing on electron api and this question I\'m trying to save recorded user screen to .webm file in videos folder in root app folder.
Actually it\'s almost working be
Your recorder.stop()
will run as follows: (from MediaRecorder docs)
When the stop() method is invoked, the UA queues a task that runs the following steps:
- If
MediaRecorder.state
is "inactive", raise a DOMInvalidState
error and terminate these steps. If theMediaRecorder.state
is not "inactive", continue on to the next step.- Set the
MediaRecorder.state
to "inactive" and stop capturing media.- Raise a
dataavailable
event containing the Blob of data that has been gathered.- Raise a
stop
event.
In your case you don't wait up the stop
event, so dataavailable
will fill blobs
only after you started the file saving method.
You have to restructure stopRecording
to ensure recorded data is available. For example:
function stopRecording () {
const save = () => {
...
}
recorder.onstop = save
recorder.stop()
}