save code
This commit is contained in:
@@ -0,0 +1,214 @@
|
||||
export type GeneralCallbackResult = {
|
||||
/** 错误信息 */
|
||||
errMsg : string
|
||||
}
|
||||
export type TakePhotoSuccessCallbackResult = {
|
||||
/** 照片文件的临时路径 (本地路径),安卓是jpg图片格式,ios是png */
|
||||
tempImagePath : string
|
||||
quality : string
|
||||
errMsg : string
|
||||
}
|
||||
/** 接口调用失败的回调函数 */
|
||||
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 = {
|
||||
/** 视频的文件的临时路径 (本地路径) */
|
||||
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 = {
|
||||
/** 视频的文件的临时路径 (本地路径) */
|
||||
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 */
|
||||
data : any
|
||||
/** 图像数据矩形的高度 */
|
||||
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 FlashMode = 'auto' | 'on' | 'off' | 'torch'
|
||||
export type DevicePosition = 'back' | 'front'
|
||||
export type Resolution = 'low' | 'medium' | 'high'
|
||||
export type FrameSize = 'medium' | 'small' | 'large'
|
||||
export type QualityType = 'high' | 'normal' | 'low' | 'original'
|
||||
|
||||
|
||||
export type CameraConfig = {
|
||||
flash ?: FlashMode
|
||||
devicePosition ?: DevicePosition
|
||||
resolution ?: Resolution
|
||||
frameSize ?: FrameSize
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
||||
export type SwitchCompleteCallback = (res : GeneralCallbackResult) => void
|
||||
/** 接口调用失败的回调函数 */
|
||||
export type SwitchFailCallback = (res : GeneralCallbackResult) => void
|
||||
/** 接口调用成功的回调函数 */
|
||||
export type SwitchSuccessCallback = (res : GeneralCallbackResult) => void
|
||||
export type SwitchOption = {
|
||||
position : DevicePosition
|
||||
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
||||
complete ?: SwitchCompleteCallback
|
||||
/** 接口调用失败的回调函数 */
|
||||
fail ?: SwitchFailCallback
|
||||
/** 接口调用成功的回调函数 */
|
||||
success ?: SwitchSuccessCallback
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
export type OnCameraFrameListenerOption = {
|
||||
success ?: OnCameraFrameCallback
|
||||
}
|
||||
|
||||
export type TakePhoto = (options : TakePhotoOption) => void
|
||||
export type SetZoom = (options : CameraContextSetZoomOption) => void
|
||||
export type StartRecord = (options : CameraContextStartRecordOption) => void
|
||||
export type StopRecord = (options : CameraContextStopRecordOption) => void
|
||||
export type OnCameraFrameListener = (options : OnCameraFrameListenerOption) => void
|
||||
export type StartCameraFrame = (options : CameraFrameListenerStartOption) => void
|
||||
export type StopCameraFrame = (options : StopOption) => void
|
||||
export type SwitchCamera = (options : SwitchOption) => void
|
||||
Reference in New Issue
Block a user