Once the new MediaRecorder has been created, we'll need to assign some eventhandlers.
The first one will be ondataavailable. This event will get fired every time a new chunk of audio is available.
We'll save all chunks of audio in an array, so we can process them later.
The saveChunkToRecording function will look something like this.

saveChunkToRecording(event) {
chunks.push(event.data);
};

The second event we handle is the onstop event. This will get fired when the MediaRecorder has stopped recording.