{ "$schema": "https://ui.shadcn.com/schema/registry-item.json", "name": "webcam", "title": "Webcam", "description": "A browser webcam streaming component with error handling and ref forwarding. | ブラウザのウェブカメラストリーミング用コンポーネント。エラー処理とref転送機能付き。", "files": [ { "path": "components/media/webcam.tsx", "content": "\"use client\";\n\nimport { useRef, useState, useEffect } from \"react\";\nimport { cn } from \"@/lib/utils\";\n\n// default video and audio settings\nconst mediaConfig = {\n video: {\n width: 640,\n height: 360,\n facingMode: \"user\",\n },\n audio: false,\n errorMessage: \"Unable to access camera\",\n};\n\nfunction mergeRefs(\n ref: React.Ref | undefined,\n localRef: React.MutableRefObject,\n) {\n return (el: T | null) => {\n localRef.current = el;\n if (typeof ref === \"function\") ref(el);\n else if (ref) (ref as React.MutableRefObject).current = el;\n };\n}\n\ninterface WebcamProps {\n ref?: React.Ref;\n width?: number; // Video width, default: 640\n height?: number; // Video height, default: 360\n audio?: boolean; // Audio, default: false\n className?: string; //