import { CameraFrame } from "./CameraFrame"; import { CameraFrameListener } from "./CameraFrameListener"; import { CameraRecordResult } from "./CameraRecordResult"; import { CameraStartRecordOptions } from "./CameraStartRecordOptions"; import { CameraStopRecordOptions } from "./CameraStopRecordOptions"; import { CameraTakePhotoOptions } from "./CameraTakePhotoOptions"; import { CameraTakePhotoResult } from "./CameraTakePhotoResult"; /** * 相机上下文。 */ export interface CameraContext { /** * 获取相机帧数据监听器。 * @param callback 处理相机帧数据的回调函数 * @returns 相机帧数据监听器 * * @example * ```javascript * const ctx = ks.createCameraContext(); * const cameraFrameListener = ctx.onCameraFrame((frame) => { * console.log(frame?.width); * console.log(frame?.height); * console.log(frame?.data.byteLength); * }); * * cameraFrameListener.start(); * * setTimeout(() => { * cameraFrameListener.stop(); * }, 3000); * * ``` * */ onCameraFrame(callback: (frame: CameraFrame) => void): CameraFrameListener; /** * 开始录像。 * @param options * @returns * * @example * ```javascript * const ctx = ks.createCameraContext(); * await ctx.startRecord({ * timeoutCallback: function (res) { * const { tempVideoPath, tempThumbPath } = res; * }, * }); * * setTimeout(async () => { * const { tempVideoPath, tempThumbPath } = await ctx.stopRecord({ * compressed: true, * }); * }, 3000); * * ``` * */ startRecord(options?: CameraStartRecordOptions): Promise; /** * 停止录像。 * @param options * @returns * * @example * ```javascript * const ctx = ks.createCameraContext(); * await ctx.startRecord({ * timeoutCallback: function (res) { * const { tempVideoPath, tempThumbPath } = res; * }, * }); * * setTimeout(async () => { * const { tempVideoPath, tempThumbPath } = await ctx.stopRecord({ * compressed: true, * }); * }, 3000); * * ``` * */ stopRecord(options?: CameraStopRecordOptions): Promise; /** * 拍摄照片。 * @param options * @returns * * @example * ```javascript * const ctx = ks.createCameraContext(); * const { tempImagePath } = await ctx.takePhoto(); * * ``` * */ takePhoto(options?: CameraTakePhotoOptions): Promise; }