Camera
createCameraContext
TIP
The API usage is as follows: CameraContext wx.createCameraContext()
- Functional description: Create the camera context CameraContext object
- Return value: CameraContext
CameraContext
- Functional description: CameraContext instance, which can be wx.createCameraContext Get. cameraContext and the only one in the page camera Component binding, operation corresponding camera Component
.onCameraFrame
TIP
The API usage is as follows: CameraFrameListener CameraContext.onCameraFrame(onCameraFrameCallback callback)
TIP
To use this interface, you must camera Specify frame-size in component properties
Functional description: Get the Camera real-time frame data.
Return value: function callback。
object.success callback function parameters: Object res。
Properties 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, one-dimensional array, each four items represent the rgba of a pixel Return value: CameraFrameListener
Sample code:
const context = wx.createCameraContext()
const listener = context.onCameraFrame((frame) => {
console.log(frame.data instanceof ArrayBuffer, frame.width, frame.height)
})
listener.start().setZoom
TIP
The API usage is as follows: CameraContext.setZoom(Object object)
Functional description: Set the zoom level.
Parameters and descriptions: Object object
Properties Type Default value Required Description zoom number - Yes Zoom level, range [1, maxZoom]. zoom can be a decimal, accurate to one decimal place. maxZoom can be obtained from the bindinitdone return value success Function - No Callback function for successful interface call fail Function - No Callback function for failed interface call complete Function - No Callback function for interface call completion (executed regardless of success or failure) object.success callback function parameters: Object res。
Properties Type Description zoom number The actual zoom level set. Due to system limitations, some models may not be able to be set to the specified value, and the closest settable value will be used instead
.startRecord
TIP
The API usage is as follows: CameraContext.startRecord(Object object)
Functional description: Start recording.
Parameters and descriptions: Object object
Properties Type Default value Required Description timeoutCallback function - No The recording will end when the time exceeds 30 seconds or the page onHide is called. This callback will also be triggered when the recording is abnormally exited. success Function - No Callback function for successful interface call fail Function - No Callback function for failed interface call complete Function - No Callback function for interface call completion (executed regardless of success or failure) object.timeoutCallback callback function parameters: Object res。
Properties Type Description tempThumbPath string The temporary path of the cover image file tempVideoPath string The temporary path of the video file
.stopRecord
TIP
The API usage is as follows: CameraContext.stopRecord(Object object)
Functional description: End recording.
Parameters and descriptions: Object object
Properties Type Default value Required Description success Function - No Callback function for successful interface call fail Function - No Callback function for failed interface call complete Function - No Callback function for interface call completion (executed regardless of success or failure) object.success callback function parameters: Object res。
Properties Type Description tempThumbPath string The temporary path of the cover image file tempVideoPath string The temporary path of the video file
.takePhoto
TIP
The API usage is as follows: CameraContext.takePhoto(Object object)
Functional description: Take a photo.
Parameters and descriptions: Object object
Properties Type Default value Required Description quality string normal No Image quality success Function - No Callback function for successful interface call fail Function - No Callback function for failed interface call complete Function - No Callback function for interface call completion (executed regardless of success or failure) Legal values
Value Description high High quality normal Normal quality low Low quality object.success callback function parameters: Object res。
Properties Type Description tempImagePath string The temporary path (local path) of the photo file, jpg image format for Android and png for iOS
CameraFrameListener
TIP
- The listener returned by CameraContext.onCameraFrame()
- For related documents, see camera。
.start
TIP
The API usage is as follows: CameraFrameListener.start(Object object)
Functional description: Start listening to frame data.
Parameters and descriptions: Object object
Properties Type Default value Required Description success Function - No Callback function for successful interface call fail Function - No Callback function for failed interface call complete Function - No Callback function for interface call completion (executed regardless of success or failure)
.stop
TIP
The API usage is as follows: CameraFrameListener.stop(Object object)
Functional description: Stop listening to frame data.
Parameters and descriptions: Object object
Properties Type Default value Required Description success Function - No Callback function for successful interface call fail Function - No Callback function for failed interface call complete Function - No Callback function for interface call completion (executed regardless of success or failure)