File size: 1,590 Bytes
f581cc4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import GlassButton from "./GlassButton";
import GlassContainer from "./GlassContainer";
import { GLASS_EFFECTS } from "../constants";

interface WebcamCaptureProps {
  isRunning: boolean;
  onToggleRunning: () => void;
  error?: string | null;
}

export default function WebcamCapture({ isRunning, onToggleRunning, error }: WebcamCaptureProps) {
  const hasError = Boolean(error);
  const [statusText, statusColor, containerBgColor] = hasError
    ? ["Error", "bg-red-500", GLASS_EFFECTS.COLORS.ERROR_BG]
    : isRunning
      ? ["Live", "bg-green-500 animate-pulse", GLASS_EFFECTS.COLORS.DEFAULT_BG]
      : ["Paused", "bg-red-500", GLASS_EFFECTS.COLORS.DEFAULT_BG];

  return (
    <>
      {/* Control buttons - positioned absolutely over the video */}
      <div className="absolute top-4 right-4 flex space-x-2 z-20">
        <GlassButton onClick={onToggleRunning} aria-label={isRunning ? "Pause captioning" : "Resume captioning"}>
          {isRunning ? "Pause" : "Resume"}
        </GlassButton>
      </div>

      {/* Status indicator with glass morphism */}
      <div className="absolute top-4 left-4 z-20">
        <GlassContainer
          bgColor={containerBgColor}
          className="px-3 py-2 rounded-lg"
          role="status"
          aria-label={`Caption status: ${statusText}`}
        >
          <div className="flex items-center space-x-2">
            <div className={`w-2 h-2 rounded-full ${statusColor}`} />
            <span className="text-white text-sm font-medium">{statusText}</span>
          </div>
        </GlassContainer>
      </div>
    </>
  );
}