Voice recording on iPhone by using Safari and HTML5

前端 未结 6 623
醉话见心
醉话见心 2020-12-24 08:08

I am developing a simple web application which only records a voice from microphone but I have some trouble.

HTML5 voice recording function works well on chrome and

6条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-24 08:48

    It's now possible and "easy" to do on iOS11 for Safari! The mediaStream API is supported now. The mediaRecorder API however is not. This causes any existing examples out there to not work. So you'll have to implement your own mediaRecorder functionality by connecting the media stream to a webkitAudioContext ScriptProcessorNode and collect the stream buffer on the node's onaudioprocess event. You can then collect the iOS microphone's streaming audio data and do with it what you want, most likely merging it into a wav file for upload/download. This works for any browser that supports the Media Stream API.

    Two gotcha's:
    - iOS Safari likes to deallocate any AudioContext that wasn't created on the main thread (on a tap) so you can't initialize it on the device media access accepted callback.
    - The scriptProccessorNode wont fire any audioprocessed events unless the input AND output are connected for some reason.

提交回复
热议问题