File size: 1,102 Bytes
2f49513
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
// SPDX-FileCopyrightText: Copyright (c) 2024-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
// SPDX-License-Identifier: BSD 2-Clause License

import { twMerge } from "tailwind-merge";
import type usePipecatWebRTC from "./hooks/use-pipecat-webrtc";

type Props = ReturnType<typeof usePipecatWebRTC>;

export default function WebRTCButton(props: Props) {
  const className = "bg-nvidia px-4 py-2 rounded-lg text-white";
  switch (props.status) {
    case "init":
      return (
        <button className={className} onClick={props.start}>
          Start
        </button>
      );
    case "connecting":
      return (
        <button className={twMerge(className, "opacity-40")} disabled>
          Connecting...
        </button>
      );
    case "connected":
      return (
        <button className={className} onClick={props.stop}>
          Stop
        </button>
      );
    case "error":
      return (
        <button
          className={className}
          onClick={props.start}
          title={props.error.message}
        >
          Error
        </button>
      );
  }
}