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.stateis "inactive", raise a DOMInvalidStateerror and terminate these steps. If theMediaRecorder.stateis not "inactive", continue on to the next step.- Set the
MediaRecorder.stateto "inactive" and stop capturing media.- Raise a
dataavailableevent containing the Blob of data that has been gathered.- Raise a
stopevent.
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()
}