// page.tsx
"use client";
import { AudioAnimationOrb, useAIVoice, Spinner } from "@tixae-labs/react-voice-orb";
import React, { useState } from "react";
import { FaCircleStop, FaMicrophone, FaMicrophoneSlash } from "react-icons/fa6";
const page = () => {
const { webCall, callState, isMuted } = useAIVoice();
const [showOrb, setShowOrb] = useState(false);
return (
<AudioAnimationOrb
orbPlaceholder={
<div
style={{
width: "100%",
height: "100%",
backgroundColor: "#e1e1e1",
borderRadius: "50%",
}}
></div>
}
showOrb={showOrb}
width={500}
height={500}
>
<div
style={{
width: 500,
height: 500,
backgroundColor: "rgba(0, 0, 0, 0.1)",
borderRadius: "100%",
display: "flex",
justifyContent: "center",
alignItems: "center",
}}
>
<div
className="ta-orb-controls"
style={{
display: "flex",
flexDirection: "column",
alignItems: "center",
justifyContent: "center",
height: "100%",
width: "100%",
backgroundColor: "transparent",
color: "#fff",
padding: "10px 20px",
borderRadius: "5px",
}}
>
<button
className="ta-button"
style={{
backgroundColor: callState === "connected" ? "rgba(250, 0, 0, 0.5)" : "rgba(0, 0, 0, 0.5)",
color: "#fff",
padding: "10px 20px",
borderRadius: "100%",
width: "100px",
height: "100px",
display: "flex",
justifyContent: "center",
alignItems: "center",
}}
onClick={() => {
if (!showOrb) {
setShowOrb(true);
return;
}
if (callState === "idle") {
webCall.startCall();
} else {
// tixaeVoice?.endCall();
webCall.toggleMute();
}
}}
>
{callState === "idle" ? (
<FaMicrophone style={{ width: "50px", height: "50px" }} />
) : null}
{callState === "connecting" ? <Spinner /> : null}
{callState === "connected" ? (
<>
{isMuted ? (
<FaMicrophoneSlash
style={{ width: "50px", height: "50px" }}
/>
) : (
<FaMicrophone style={{ width: "50px", height: "50px" }} />
)}
</>
) : null}
</button>
{callState === "connected" ? (
<>
<button
style={{
marginTop: `10px`,
display: `flex`,
alignItems: `center`,
justifyContent: `center`,
gap: `10px`,
padding: `10px 20px`,
backgroundColor: `rgba(0, 0, 0, 0.5)`,
borderRadius: `10px`,
}}
className="ta-button-end"
onClick={() => {
webCall.endCall();
}}
>
End Call
<FaCircleStop style={{ width: "20px", height: "20px" }} />
</button>
</>
) : null}
</div>
</div>
</AudioAnimationOrb>
);
};
export default page;