score:5

Accepted answer

safari support:

i was able to add support for mediarecorder api in safari by using audio recorder polyfill. you can check this npm package here.

steps (react js):

  1. install the package using npm i audio-recorder-polyfill
  2. add this piece of code in public/index.html. this will make sure that the polyfill is loaded only for the browsers which do not support mediarecorder api.
<script>
  // load this bundle only for browsers without mediarecorder support
  if (!window.mediarecorder) {
    document.write(
      decodeuri('%3cscript defer src="/polyfill.js">%3c/script>')
    )
  }
</script>
  1. add this piece of code in src/index.tsx or src/index.js. this will assign this polyfill to mediarecorder present in window object.
import audiorecorder from 'audio-recorder-polyfill'
window.mediarecorder = audiorecorder
  1. if you are using typescript, you might have to add type declarations in src/audio-recorder-polyfill.d.ts
declare module 'audio-recorder-polyfill'

Related Query

More Query from same tag