How to record audio and video in safari browser in iOS devices and Mac OS devices?

Stuck with the implementation to Record Audio & Video in safari browsers.

What I have tried:

I tried using WebRTC to get access to the Microphone and Camera, I was able to show the permissions but I’m unable to get access to the devices. Below is my code:

navigator.mediaDevices.getUserMedia = function(constraintObj) {
                                let getUserMedia = navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.getUserMedia;

I keep getting the below error messages:

getUserMedia is not implemented in this browser

Can't find variable: MediaRecorder

I was able to record a video from iPhone using the below code, but the same code doesn’t work for audio.

<input id="recordUploadFile" style="visibility:hidden;" class="recordFile" type="file" accept="video/*" onChange='getFileNameWithExt(event, "record")' capture>

Unable to figure out below 2 cases:

  • iOS devices – Audio Recording
  • MacOS – Video and Audio Recording

Source: Ios Questions