bricks/docs/zh/camera.md
2025-11-19 12:30:39 +08:00

27 lines
1.2 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Camera
控件功能:用于调用设备摄像头进行拍照或视频录制,支持切换摄像头、开始/停止录制、拍摄照片等功能。
类型:普通控件(基于 `Popup` 的扩展)
父类控件:`bricks.Popup`
## 初始化参数
| 参数名 | 类型 | 说明 |
|-------|------|------|
| `fps` | Number | 视频采集帧率,默认为 60 FPS |
| `type` | String | 控件模式,可选值为 `'picture'`(拍照模式)或 `'recorder'`(录像模式) |
| `auto_dismiss` | Boolean | 是否自动关闭弹窗,默认为 `false`(由代码中显式设置) |
> 注意:`opts.auto_dismiss = false;` 在构造函数中被强制设置。
## 主要事件
| 事件名 | 触发条件 | 携带数据 |
|--------|--------|--------|
| `shot` | 用户点击拍照按钮时触发 | 拍摄得到的图片数据 URLbase64 格式的 JPEG 图像) |
| `recorded` | 视频录制结束后触发 | 录制完成的视频文件对象(`File` 类型,格式为 WebM |
> 说明:
> - 当 `type='picture'` 时,点击拍摄按钮会触发 `shot` 事件并传出图像数据。
> - 当 `type='recorder'` 时,点击录制按钮开始/停止录制,停止后触发 `recorded` 事件并传出视频文件。