@osmandvc/react-upload-control-components
Version:
UI components for the react-upload-control library.
59 lines (58 loc) • 2.02 kB
TypeScript
import React from "react";
interface ScreenshotDimensions {
width: number;
height: number;
}
interface ChildrenProps {
getScreenshot: (screenshotDimensions?: ScreenshotDimensions) => string | null;
}
export type WebcamProps = Omit<React.HTMLProps<HTMLVideoElement>, "ref"> & {
audio: boolean;
audioConstraints?: MediaStreamConstraints["audio"];
forceScreenshotSourceSize: boolean;
imageSmoothing: boolean;
mirrored: boolean;
minScreenshotHeight?: number;
minScreenshotWidth?: number;
onUserMedia: (stream: MediaStream) => void;
onUserMediaError: (error: string | DOMException) => void;
screenshotFormat: "image/webp" | "image/png" | "image/jpeg";
screenshotQuality: number;
videoConstraints?: MediaStreamConstraints["video"];
children?: (childrenProps: ChildrenProps) => JSX.Element;
};
interface WebcamState {
hasUserMedia: boolean;
src?: string;
}
export default class Webcam extends React.Component<WebcamProps, WebcamState> {
static defaultProps: {
audio: boolean;
forceScreenshotSourceSize: boolean;
imageSmoothing: boolean;
mirrored: boolean;
onUserMedia: () => undefined;
onUserMediaError: () => undefined;
screenshotFormat: string;
screenshotQuality: number;
};
private canvas;
private ctx;
private requestUserMediaId;
private unmounted;
private requestedUserMedia;
stream: MediaStream | null;
video: HTMLVideoElement | null;
constructor(props: WebcamProps);
componentDidMount(): void;
componentDidUpdate(nextProps: WebcamProps): void;
componentWillUnmount(): void;
private static stopMediaStream;
private stopAndCleanup;
getScreenshot(screenshotDimensions?: ScreenshotDimensions): string | null;
getCanvas(screenshotDimensions?: ScreenshotDimensions): HTMLCanvasElement | null;
private requestUserMedia;
private handleUserMedia;
render(): import("react/jsx-runtime").JSX.Element;
}
export {};