Safari 和录制音频 — HTML 媒体捕获/getUserMedia() [英] Safari and Recording Audio — HTML Media Capture / getUserMedia()

查看:40
本文介绍了Safari 和录制音频 — HTML 媒体捕获/getUserMedia()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

看起来

iOS 10.3 上的 Safari 还支持 capture 布尔属性.它表示直接从网络摄像头捕获是首选.使用时,iOS 10.3+ 上的 Safari 将不会提供选择现有视频或图像的选项:

我在 https 上写了更多关于 HTML 媒体捕获主题的文章://addpipe.com/blog/correct-syntax-html-media-capture/

It looks like getUserMedia() is now the way to go for capturing audio recordings from a user.

But that leaves out Safari and iOS Safari.

Originally I had at least planned to included iOS Safari by taking advantage of the HTML Media Capture spec. From everything I've read, this is suppose to work. But from my tests, iOS will only offer the photo/video options. I've tried the following syntaxes with no luck:

<input type="file" accept="audio/*;capture=microphone" />
<input type="file" accept="audio/*" capture="microphone">
<input type="file" accept="audio/*" />

Capturing an image works as expected, though, allowing the user to use the camera:

<input type="file" accept="image/*" />

What do I need to change in order to get iOS Safari to work with HTML Media Capture when needing access to the microphone?

And are there any other options available for both Safari and iOS Safari other than what I'm already attempting to do?

解决方案

Safari on iOS 6+ supports the HTML Media Capture spec but only for videos and photos:

  • <input type="file" accept="image/*" />
  • <input type="file" accept="video/*" />

It does not support audio only capture so the following will not produce the expected outcome:

  • <input type="file" accept="audio/*" />

Android supports all 3 (video, audio, image).

Thus support across Android and iOS is as follows:

With Safari on iOS 10.3 the capture boolean attribute is also supported. It indicates capture directly from the webcam is preferred. When used, the option to choose an existing video or image will not be offered on Safari on iOS 10.3+:

  • <input type="file" accept="image/*" capture />

I've written more on the HTML Media Capture topic at https://addpipe.com/blog/correct-syntax-html-media-capture/

这篇关于Safari 和录制音频 — HTML 媒体捕获/getUserMedia()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆