May 18, 2021 WeChat Mini Program Development Document
CameraContext instance, available at wx.createCameraContext.
CameraContext is bound to the unique camera component within the page, which operates the corresponding camera component.
Base library 2.7.0 starts to support, and low versions need to be compatible.
Get Camera real-time frame data
Callback function
Property | Type | Description |
---|---|---|
width | number | The width of the image data rectangle |
height | number | The height of the image data rectangle |
data | ArrayBuffer | Image pixel data, a one-dimensional array, each of which represents a pixel rgba |
Note: Using this interface requires specifying frame-size in the camera component properties at the same time.
const context = wx.createCameraContext()
const listener = context.onCameraFrame((frame) => {
console.log(frame.data instanceof ArrayBuffer, frame.width, frame.height)
})
listener.start()
Base library 2.10.0 starts to support, and low versions need to be compatible.
Set the zoom level
Property | Type | The default | Required | Description |
---|---|---|---|---|
zoom | number | Is | Zoom level, range 1, maxZoom. Z oom is desirable for a small number, accurate to the next place in the count. MaxZoom is available in the bindinitdone return value. | |
success | function | Whether | The interface calls a successful callback function | |
fail | function | Whether | The interface calls the failed callback function | |
complete | function | Whether | Callback function at end of interface call (call succeeds, fails are executed) |
Property | Type | Description |
---|---|---|
zoom | number | The zoom level that is actually set. Due to system limitations, some models may not be able to set a specified value and will use the nearest setable value between. |
Start recording
Property | Type | The default | Required | Description |
---|---|---|---|---|
timeoutCallback | function | Whether |
The recording ends when more than 30s or the page
onHide
|
|
success | function | Whether | The interface calls a successful callback function | |
fail | function | Whether | The interface calls the failed callback function | |
complete | function | Whether | Callback function at end of interface call (call succeeds, fails are executed) |
Property | Type | Description |
---|---|---|
tempThumbPath | string | Temporary path to cover picture file (local path) |
tempVideoPath | string | Temporary path for video files (local path) |
End the recording
Property | Type | The default | Required | Description |
---|---|---|---|---|
compressed | boolean | false | Whether |
Start video compression, which works the same
chooseVideo
|
success | function | Whether | The interface calls a successful callback function | |
fail | function | Whether | The interface calls the failed callback function | |
complete | function | Whether | Callback function at end of interface call (call succeeds, fails are executed) |
Property | Type | Description |
---|---|---|
tempThumbPath | string | Temporary path to cover picture file (local path) |
tempVideoPath | string | Temporary path for video files (local path) |
Take a photo
Property | Type | The default | Required | Description |
---|---|---|---|---|
quality | string | normal | Whether | Image quality |
success | function | Whether | The interface calls a successful callback function | |
fail | function | Whether | The interface calls the failed callback function | |
complete | function | Whether | Callback function at end of interface call (call succeeds, fails are executed) |
The legal value of object.quality
Value | Description | The lowest version |
---|---|---|
high | Quality | |
normal | Ordinary quality | |
low | Low quality |
Property | Type | Description |
---|---|---|
tempImagePath | string | Photo file temporary path (local path), Android is jpg picture format, ios is png |