HTML attribute: capture - HTML: HyperText Markup Language 编辑

Draft

This page is not complete.

The capture attribute specifies that, optionally, a new file should be captured, and which device should be used to capture that new media of a type defined by the /wiki/en-US/docs/Web/HTML/Attributes/accept attribute. Values include user and environment. The capture attribute is supported on the file input type.

The capture attribute takes as it's value a string that specifies which camera to use for capture of image or video data, if the /wiki/en-US/docs/Web/HTML/Attributes/accept attribute indicates that the input should be of one of those types.

ValueDescription
userThe user-facing camera and/or microphone should be used.
environmentThe outward-facing camera and/or microphone should be used

Note: capture was previously a Boolean attribute which, if present, requested that the device's media capture device(s) such as camera or microphone be used instead of requesting a file input.

Examples

When set on a file input type, operating systems with microphones and cameras will display a user interface allowing the selection from an existing file or the creating of a new one.

<p>
	<label for="soundFile">What does your voice sound like?:</label>
	<input type="file" id="soundFile" capture="user" /wiki/en-US/docs/Web/HTML/Attributes/accept="audio/*">
	</p>
	<p>
	<label for="videoFile">Upload a video:</label>
	<input type="file" id="videoFile" capture="environment" /wiki/en-US/docs/Web/HTML/Attributes/accept="video/*">
	</p>
	<p>
	<label for="imageFile">Upload a photo of yourself:</label>
	<input type="file" id="imageFile" capture="user" /wiki/en-US/docs/Web/HTML/Attributes/accept="image/*">
	</p>

Note these work better on mobile devices; if your device is a desktop computer, you'll likely get a typical file picker.

Specifications

SpecificationStatus
HTML Media Capture
The definition of 'capture attribute' in that specification.
Recommendation

See also

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:63 次

字数:4120

最后编辑:6 年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文