开发文档首页
- 网络
- 媒体
- 文件
- wx.saveFile
- wx.getFileInfo
- wx.getSavedFileList
- wx.getSavedFileInfo
- wx.removeSavedFile
- wx.openDocument
- 文件管理器
- FileSystemManager
- wx.getFileSystemManager
- FileSystemManager.appendFile
- FileSystemManager.access
- FileSystemManager.accessSync
- FileSystemManager.appendFileSync
- FileSystemManager.copyFile
- FileSystemManager.copyFileSync
- FileSystemManager.getSavedFileList
- FileSystemManager.getFileInfo
- FileSystemManager.mkdir
- FileSystemManager.mkdirSync
- FileSystemManager.removeSavedFile
- FileSystemManager.readFileSync
- FileSystemManager.renameSync
- FileSystemManager.rmdirSync
- FileSystemManager.readdir
- FileSystemManager.rename
- FileSystemManager.readFile
- FileSystemManager.rmdir
- FileSystemManager.readdirSync
- FileSystemManager.saveFile
- FileSystemManager.saveFileSync
- FileSystemManager.stat
- FileSystemManager.statSync
- Stats
- Stats.isDirectory
- Stats.isFile
- FileSystemManager.unlink
- FileSystemManager.unzip
- FileSystemManager.unlinkSync
- FileSystemManager.writeFile
- FileSystemManager.writeFileSync
- 数据缓存
- 位置
- 设备
- 系统信息
- 内存
- 网络状态
- 加速度计
- 罗盘
- 拨打电话
- 扫码
- 剪贴板
- 蓝牙
- wx.openBluetoothAdapter
- wx.closeBluetoothAdapter
- wx.getBluetoothAdapterState
- wx.onBluetoothAdapterStateChange
- wx.startBluetoothDevicesDiscovery
- wx.stopBluetoothDevicesDiscovery
- wx.getBluetoothDevices
- wx.getConnectedBluetoothDevices
- wx.onBluetoothDeviceFound
- wx.createBLEConnection
- wx.closeBLEConnection
- wx.getBLEDeviceServices
- wx.getBLEDeviceCharacteristics
- wx.readBLECharacteristicValue
- wx.writeBLECharacteristicValue
- wx.notifyBLECharacteristicValueChange
- wx.onBLEConnectionStateChange
- wx.onBLECharacteristicValueChange
- 错误码
- iBeacon
- 屏幕亮度
- 用户截屏事件
- 振动
- 手机联系人
- NFC
- Wi-Fi
- 界面
- 交互反馈
- 设置导航条
- 设置tabBar
- 设置窗口背景
- 设置置顶信息
- 导航
- 动画
- 位置
- 绘图
- intro
- coordinates
- gradient
- reference
- color
- wx.createCanvasContext
- wx.createContext
- wx.drawCanvas
- wx.canvasToTempFilePath
- wx.canvasGetImageData
- wx.canvasPutImageData
- setFillStyle
- setStrokeStyle
- setShadow
- createLinearGradient
- createCircularGradient
- addColorStop
- setLineWidth
- setLineCap
- setLineJoin
- setLineDash
- setMiterLimit
- rect
- fillRect
- strokeRect
- clearRect
- fill
- stroke
- beginPath
- closePath
- moveTo
- lineTo
- arc
- bezierCurveTo
- quadraticCurveTo
- scale
- rotate
- translate
- clip
- setFontSize
- fillText
- setTextAlign
- setTextBaseline
- drawImage
- setGlobalAlpha
- save
- restore
- draw
- getActions
- clearActions
- measureText
- globalCompositeOperation
- arcTo
- strokeText
- lineDashOffset
- createPattern
- shadowBlur
- shadowColor
- shadowOffsetX
- shadowOffsetY
- font
- transform
- setTransform
- 下拉刷新
- WXML节点信息
- WXML节点布局相交状态
- 自定义组件
- 第三方平台
- 开放接口
- 数据
- 更新
- 多线程
- 监控
- 调试接口
- 日志
本页面已暂停更新,请查看[最新文档](https://developers.weixin.qq.com/miniprogram/dev/api/media/camera/wx.createCameraContext.html)
基础库 1.6.0 开始支持,低版本需做兼容处理。
创建并返回 camera 上下文 cameraContext 对象,cameraContext 与页面的 camera 组件绑定,一个页面只能有一个camera,通过它可以操作对应的 <camera/> 组件。 在自定义组件下,第一个参数传入组件实例this,以操作组件内 <camera/> 组件
cameraContext 对象的方法列表:
| 方法 | 参数 | 说明 |
|---|---|---|
| takePhoto | OBJECT | 拍照,可指定质量,成功则返回图片 |
| startRecord | OBJECT | 开始录像 |
| stopRecord | OBJECT | 结束录像,成功则返回封面与视频 |
takePhoto 的 OBJECT 参数列表:
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| quality | String | 否 | 成像质量,值为high, normal, low,默认normal |
| success | Function | 否 | 接口调用成功的回调函数 ,res = { tempImagePath } |
| fail | Function | 否 | 接口调用失败的回调函数 |
| complete | Function | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
startRecord 的 OBJECT 参数列表:
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| success | Function | 否 | 接口调用成功的回调函数 |
| fail | Function | 否 | 接口调用失败的回调函数 |
| complete | Function | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
| timeoutCallback | Function | 否 | 超过30s或页面onHide时会结束录像,res = { tempThumbPath, tempVideoPath } |
stopRecord 的 OBJECT 参数列表:
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| success | Function | 否 | 接口调用成功的回调函数 ,res = { tempThumbPath, tempVideoPath } |
| fail | Function | 否 | 接口调用失败的回调函数 |
| complete | Function | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
示例代码:
在开发者工具中预览效果