-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathAdditionalControls.tsx
More file actions
93 lines (80 loc) · 2.61 KB
/
Copy pathAdditionalControls.tsx
File metadata and controls
93 lines (80 loc) · 2.61 KB
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
import { useCamera, useMicrophone } from "@fishjam-cloud/react-client";
import { useAtom } from "jotai";
import { atomWithStorage } from "jotai/utils";
import AudioVisualizer from "./AudioVisualizer";
import VideoPlayer from "./VideoPlayer";
const showAdditionalComponentAtom = atomWithStorage(
"show-additional-component",
false,
);
export const AdditionalControls = () => {
const camera = useCamera();
const microphone = useMicrophone();
const [show, setShow] = useAtom(showAdditionalComponentAtom);
return (
<div>
<div className="flex flex-row p-2">
<div className="m-2">Separate component</div>
<button
className={`btn btn-sm ${show ? "btn-info" : "btn-success"}`}
onClick={() => {
setShow(!show);
}}
>
{show ? "Hide" : "Show"}
</button>
</div>
{show && (
<div className="flex flex-row flex-wrap gap-2 p-2 md:grid md:grid-cols-2">
<div className="grid grid-cols-2 gap-2">
<div className="flex flex-col gap-2">
<button
className="btn btn-success btn-sm"
onClick={() => {
camera.toggleCamera();
}}
>
Toggle camera (it's now {camera.isCameraOn ? "on" : "off"})
</button>
</div>
<div className="flex flex-col gap-2">
<button
className="btn btn-success btn-sm"
onClick={() => {
microphone.toggleMicrophone();
}}
>
Toggle camera (it's now{" "}
{microphone.isMicrophoneOn ? "on" : "off"})
</button>
<button
className="btn btn-success btn-sm"
onClick={() => {
microphone.toggleMicrophoneMute();
}}
>
Toggle camera mute (it's now{" "}
{microphone.isMicrophoneMuted ? "muted" : "unmuted"})
</button>
</div>
</div>
<div>
<h3>Local:</h3>
<div className="max-w-[500px]">
{camera.cameraStream && (
<VideoPlayer stream={camera.cameraStream} />
)}
{microphone.microphoneStream && (
<AudioVisualizer
stream={microphone.microphoneStream}
trackId={microphone.activeMicrophone?.deviceId}
/>
)}
</div>
</div>
</div>
)}
</div>
);
};
export default AdditionalControls;