Voice recording on iPhone by using Safari and HTML5

好久不见. 提交于 2019-12-17 22:24:28

问题


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 firefox desktop or android. But while using mobile browsers on iPhone even chrome and firefox it doesn't work.

I tried recorder.js and result did not change.

Is it possible to recording voice on safari or it is a missing function of safari or iOS?


回答1:


As far as I knew, even on the latest iOS (iOS 10), recording voice on iOS using HTML5 is still impossible. Since all the browsers on iOS are limited to use UIWebView which Safari on iOS uses as well, Chrome on iOS is not able to support any API that can be used for media recording.
For example, recorder.js which you used are built on Media Capture API. If you check caniuse.com, you will find this API is not supported on iOS. (Also check the issue here).
MediaRecorder API is also a promising API but still not supported by Apple's browser.

Check answers below for more information.
1. Record voice from IPhone using HTML5
2. Audio Recording html5 on iOS




回答2:


Since iOS11, Safari now supports Media Capture API:

New in Safari 11.0 – Camera and microphone access.

Added support for the Media Capture API. Added ability for websites to access camera and microphone streams from a user's device (user permission is required.)

Announcement by Apple - broken link as of Jul 2018

A copy of the announcement on someone's blog

Therefore recorder.js will work now.




回答3:


May 2018 Update (because figuring this out has been tough with all the outdated info).

I found this demo that proves it is possible: https://kaliatech.github.io/web-audio-recording-tests/dist/#/test1




回答4:


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.




回答5:


Safari on iOS 11 does NOT support the 2 standards which would make audio (only) recording possible (and easy to implement):

  • HTML Media Capture for audio (spec, correct syntax ) - audio recording should be passed to a native app which should pass the result back to the browser for upload (it works for video and picture)
  • MediaStream Recording API (spec, demo) - allows you to record to a blob directly in the browser. The recording can be downloaded or uploaded to a web server.


来源:https://stackoverflow.com/questions/42221646/voice-recording-on-iphone-by-using-safari-and-html5

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!