How to record audio on webpage (iOS, Android, PC/Mac) - no flash

前端 未结 3 1457
萌比男神i
萌比男神i 2020-12-07 17:41

I have a requirement to allow a user to record an audio file using their microphone, but it has to work without flash as it needs to work on iOS (mobile safari), Android bro

3条回答
  •  孤街浪徒
    2020-12-07 18:39

    getUserMedia() is now widely supported across mobile:

    • Safari on iOS 11 (except UIWebView)
    • Chrome on Android

    and desktop:

    • Safari 11
    • Chrome
    • Firefox
    • Edge 12
    • Opera

    Once webcam/mic permission is given and the mic data kicks in you can:

    • encode the sound using JS libraries like Recorder.js (wav), WebAudioRecorder.js (wav,mp3,Vorbis) or vmsg (mp3).
    • or use the (native) Media Recorder API to capture Opus audio in .ogg (Firefox) and .webm (Chrome) files together with this neat polyfill for Safari 11 and Edge that produces .wav files.

    Here's a demo I made (live demo, source on GitHub) that uses Matt Diamond's Recorder.js to record audio (pcm in .wav files) running in Safari on iOS 11. Clicking Record prompts the user to allow microphone access:

提交回复
热议问题