daShangDao_scanBook/uni_modules/lime-camera/utssdk/interface.uts

227 lines
8.3 KiB
Plaintext
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.

// #ifdef APP-ANDROID
import ImageProxy from 'androidx.camera.core.ImageProxy';
// #endif
export type GeneralCallbackResult = {
/** 错误信息 */
errMsg : string
}
export type TakePhotoSuccessCallbackResult = {
/** 照片文件的临时路径 (本地路径)安卓是jpg图片格式ios是png */
tempImagePath : string
errMsg : string
}
export type TakePhotoCallback = (res: string) => void
/** 接口调用失败的回调函数 */
export type TakePhotoFailCallback = (res : GeneralCallbackResult) => void
/** 接口调用成功的回调函数 */
export type TakePhotoSuccessCallback = (
result : TakePhotoSuccessCallbackResult
) => void
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
export type TakePhotoCompleteCallback = (res : GeneralCallbackResult) => void
export type TakePhotoOption = {
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
complete ?: TakePhotoCompleteCallback
/** 接口调用失败的回调函数 */
fail ?: TakePhotoFailCallback
/** 成像质量
*
* 可选值:
* - 'high': 高质量;
* - 'normal': 普通质量;
* - 'low': 低质量;
* - 'original': 原图; */
quality ?: 'high' | 'normal' | 'low' | 'original'
/**
* 是否开启镜像 */
selfieMirror ?: boolean
/** 接口调用成功的回调函数 */
success ?: TakePhotoSuccessCallback
}
export type SetZoomSuccessCallbackResult = {
/** 实际设置的缩放级别。由于系统限制,某些机型可能无法设置成指定值,会改用最接近的可设值。 */
zoom : number
errMsg : string
}
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
export type SetZoomCompleteCallback = (res : GeneralCallbackResult) => void
/** 接口调用失败的回调函数 */
export type SetZoomFailCallback = (res : GeneralCallbackResult) => void
/** 接口调用成功的回调函数 */
export type CameraContextSetZoomSuccessCallback = (
result : SetZoomSuccessCallbackResult
) => void
export type CameraContextSetZoomOption = {
/** 缩放级别,范围[1, maxZoom]。zoom 可取小数精确到小数后一位。maxZoom 可在 bindinitdone 返回值中获取。 */
zoom : number
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
complete ?: SetZoomCompleteCallback
/** 接口调用失败的回调函数 */
fail ?: SetZoomFailCallback
/** 接口调用成功的回调函数 */
success ?: CameraContextSetZoomSuccessCallback
}
export type StartRecordTimeoutCallbackResult = {
/** 封面图片文件的临时路径 (本地路径) */
tempThumbPath : string
/** 视频的文件的临时路径 (本地路径) */
tempVideoPath : string
}
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
export type StartRecordCompleteCallback = (res : GeneralCallbackResult) => void
/** 接口调用失败的回调函数 */
export type StartRecordFailCallback = (res : GeneralCallbackResult) => void
/** 超过录制时长上限时会结束录像并触发此回调,录像异常退出时也会触发此回调 */
export type StartRecordTimeoutCallback = (
result : StartRecordTimeoutCallbackResult
) => void
/** 接口调用成功的回调函数 */
export type CameraContextStartRecordSuccessCallback = (
res : GeneralCallbackResult
) => void
export type CameraContextStartRecordOption = {
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
complete ?: StartRecordCompleteCallback
/** 接口调用失败的回调函数 */
fail ?: StartRecordFailCallback
/**
* 是否开启镜像 */
selfieMirror ?: boolean
/** 接口调用成功的回调函数 */
success ?: CameraContextStartRecordSuccessCallback
/**
* 录制时长上限,单位为秒,最长不能超过 5 分钟 */
timeout ?: number
/** 超过录制时长上限时会结束录像并触发此回调,录像异常退出时也会触发此回调 */
timeoutCallback ?: StartRecordTimeoutCallback
}
export type StopRecordSuccessCallbackResult = {
/** 封面图片文件的临时路径 (本地路径) */
tempThumbPath : string
/** 视频的文件的临时路径 (本地路径) */
tempVideoPath : string
errMsg : string
}
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
export type StopRecordCompleteCallback = (res : GeneralCallbackResult) => void
/** 接口调用失败的回调函数 */
export type StopRecordFailCallback = (res : GeneralCallbackResult) => void
/** 接口调用成功的回调函数 */
export type CameraContextStopRecordSuccessCallback = (
result : StopRecordSuccessCallbackResult
) => void
export type CameraContextStopRecordOption = {
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
complete ?: StopRecordCompleteCallback
/** 启动视频压缩,压缩效果同`chooseVideo` */
compressed ?: boolean
/** 接口调用失败的回调函数 */
fail ?: StopRecordFailCallback
/** 接口调用成功的回调函数 */
success ?: CameraContextStopRecordSuccessCallback
}
/** 回调函数 */
export type OnCameraFrameCallback = (result : OnCameraFrameCallbackResult) => void
export type OnCameraFrameCallbackResult = {
/** 图像像素点数据,一维数组,每四项表示一个像素点的 rgba */
// #ifdef APP-ANDROID
data : ImageProxy
// #endif
// #ifndef APP-ANDROID
data : ArrayBuffer
// #endif
/** 图像数据矩形的高度 */
height : number
/** 图像数据矩形的宽度 */
width : number
}
/** 接口调用成功的回调函数 */
export type StartSuccessCallback = (res : GeneralCallbackResult) => void
/** 接口调用失败的回调函数 */
type StartFailCallback = (res : GeneralCallbackResult) => void
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
type StartCompleteCallback = (res : GeneralCallbackResult) => void
export type CameraFrameListenerStartOption = {
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
complete ?: StartCompleteCallback
/** 接口调用失败的回调函数 */
fail ?: StartFailCallback
/** 接口调用成功的回调函数 */
success ?: StartSuccessCallback
/** [Worker](https://developers.weixin.qq.com/miniprogram/dev/api/worker/Worker.html)
*
* 可选参数。如果需要在 iOS ExperimentalWorker 内监听摄像头帧数据,则需要传入对应 Worker 对象。详情 [Worker.getCameraFrameData](https://developers.weixin.qq.com/miniprogram/dev/api/worker/Worker.getCameraFrameData.html) */
// worker ?: Worker
}
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
export type StopCompleteCallback = (res : GeneralCallbackResult) => void
/** 接口调用失败的回调函数 */
export type StopFailCallback = (res : GeneralCallbackResult) => void
/** 接口调用成功的回调函数 */
export type StopSuccessCallback = (res : GeneralCallbackResult) => void
export type StopOption = {
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
complete ?: StopCompleteCallback
/** 接口调用失败的回调函数 */
fail ?: StopFailCallback
/** 接口调用成功的回调函数 */
success ?: StopSuccessCallback
}
// export type CameraFrameListener = {
// /**
// * 开始监听帧数据 */
// start(option ?: CameraFrameListenerStartOption) : void
// /**
// * 停止监听帧数据 */
// stop(option ?: StopOption) : void
// }
export type FlashMode = 'auto' | 'on' | 'off' | 'torch'
export type DevicePosition = 'back' | 'front'
export type Resolution = 'low' | 'medium' | 'high'
export type FrameSize = 'medium' | 'small' | 'large'
// type OutputDimension = '360P' | '540P' | '720P' | '1080P' | 'max'
export type QualityType = 'high' | 'normal' | 'low' | 'original'
export type CameraConfig = {
flash ?: FlashMode
devicePosition ?: DevicePosition
resolution ?: Resolution
frameSize ?: FrameSize
focus ?: boolean
// outputDimension ?: OutputDimension
}
export interface CameraFrameListener {
start():void
start(option ?: CameraFrameListenerStartOption):void
stop():void
stop(option ?: StopOption):void
}
export interface CameraContext {
takePhoto(option : TakePhotoOption):void
setZoom(option : CameraContextSetZoomOption):void
startRecord(option : CameraContextStartRecordOption):void
stopRecord(option : CameraContextStopRecordOption) :void
onCameraFrame():CameraFrameListener
onCameraFrame(callback : OnCameraFrameCallback | null) : CameraFrameListener
}