import { Ref, CSSProperties, ReactElement } from "react"; import CameraPreviewVideo from "./common/CameraPreview/CameraPreviewVideo"; import CameraPreviewPlugin, { IPluginConf } from "./common/CameraPreview/CameraPreviewPlugin"; import { modeType } from "./common/constant"; export interface IInitParams { /** 初始化函数 */ init: Function; /** 开启视频流 */ onPlay: Function; /** 关闭视频流 */ onClose: Function; /** 从视频流中获取图片 img 元素 */ getPicImg: Function; /** 从视频流中获取 canvas 元素 */ getPicCanvas: Function; /** 从视频流中获取图片 base64 字符串 */ getPicBase64: Function; /** video 标签 Ref */ videoRef: Ref; /** player 标签 Ref */ playerRef: Ref; } export interface ICameraPreviewerProps { /** 容器类名 */ className?: string; /** 容器行内样式 */ wrapStyle?: CSSProperties; /** 是否自动开始 */ autoStart?: boolean; /** * 预览模式 * video: video 标签 * pluginCameraPreview: cordova-plugin-camera-preview 插件 */ mode?: (typeof modeType)[keyof typeof modeType]; /** 加载成功回调 */ init?: (params: IInitParams) => void; /** 视频流配置 */ videoConf?: IPluginConf; videoStyle?: CSSProperties; /** 子元素 */ children?: ReactElement; /** 子元素渲染函数,解决 children 更新无法触发的问题 */ ChildrenRender?: () => ReactElement; /** 指定挂载的节点,但依旧为全局展示,false 为挂载在当前位置*/ getContainer?: HTMLElement | (() => HTMLElement) | false; } export interface IInitConf { /** video 元素 */ video?: HTMLVideoElement; /** 视频流配置 */ videoConf?: IPluginConf; }