// ============================================================
// VideoPreview — 摄像头画面预览
// 职责：显示实时摄像头画面
// ============================================================

import { forwardRef } from "react";
import { useI18n } from "../../lib/i18n";

interface VideoPreviewProps {
  isStreaming: boolean;
}

export const VideoPreview = forwardRef<HTMLVideoElement, VideoPreviewProps>(
  function VideoPreview({ isStreaming }, ref) {
    const { t } = useI18n();

    return (
      <div className="video-preview">
        <video
          ref={ref}
          autoPlay
          playsInline
          muted
          className="video-preview__video"
        />
        {!isStreaming && (
          <div className="video-preview__placeholder">
            {t("video.cameraOff")}
          </div>
        )}
      </div>
    );
  }
);
