@@ -20,6 +20,7 @@ import { IoVideocamOutline as VideoOnIcon } from "react-icons/io5";
2020 import { IoVideocamOffOutline as VideoOffIcon } from "react-icons/io5";
2121
2222 import useNoiseReduction from "@/hooks/agora-ai-noise-reduction";
23+import useVirtualBackground from "@/hooks/agora-virtual-background";
2324
2425 import { Modal } from "./modal";
2526 import PrimaryButton from "./primary-button";
@@ -78,6 +79,19 @@ export default function AgoraHost() {
7879 setVideoStarted(!videoStarted);
7980 }, [videoStarted]);
8081
82+ const virtualBackgroundRef = useVirtualBackground({ localCameraTrack });
83+
84+ const handleBlurBackground = useCallback(() => {
85+ const enableBlur = async () => {
86+ virtualBackgroundRef.current?.setOptions({
87+ type: "blur",
88+ blurDegree: 2,
89+ });
90+ virtualBackgroundRef.current?.enable();
91+ };
92+ void enableBlur();
93+ }, [virtualBackgroundRef]);
94+
8195 useJoin(
8296 {
8397 appid: appId,
@@ -146,62 +160,69 @@ export default function AgoraHost() {
146160 </div>
147161 </PrimaryButton>
148162 </button>
149- <Modal
150- openButton={
151- <button
152- onClick={() => setShowSettingsModal(!showSettingsModal)}
153- >
154- <SecondaryButton>
155- <div className="py-2 px-4 flex flex-row gap-2 items-center">
156- <GearIcon size="2em" />
157- <p>Settings</p>
158- </div>
159- </SecondaryButton>
160- </button>
161- }
162- showModal={showSettingsModal}
163- >
164- <div className="p-4 bg-stone-800 rounded-2xl flex flex-col gap-4">
165- <div>
166- <h4 className="font-bold pb-4">
167- Select your video device:
168- </h4>
169- {availableCameras.map((c) => {
170- return (
171- <label key={c.id} className="flex flex-row gap-2">
172- <input
173- type="radio"
174- name="selected-camera"
175- value={c.id}
176- checked={c.id === selectedCameraId}
177- onChange={(e) => {
178- const id = e.target.value;
179- setSelectedCameraId(id);
180- }}
181- />
182- <div>{c.label}</div>
183- </label>
184- );
185- })}
186- </div>
187-
188- <div className="text-center">
189- <button onClick={() => setShowSettingsModal(false)}>
190- <PrimaryButton>
191- <p className="px-4 py-2">Close</p>
192- </PrimaryButton>
193- </button>
194- </div>
195- </div>
196- </Modal>
197163 </div>
198164 )}
199165 </div>
200166 </LocalUser>
201167 </div>
202168
169+ <Modal
170+ openButton={
171+ <button onClick={() => setShowSettingsModal(!showSettingsModal)}>
172+ <SecondaryButton>
173+ <div className="py-2 px-4 flex flex-row gap-2 items-center">
174+ <GearIcon size="2em" />
175+ <p>Settings</p>
176+ </div>
177+ </SecondaryButton>
178+ </button>
179+ }
180+ showModal={showSettingsModal}
181+ >
182+ <div className="p-4 bg-stone-800 rounded-2xl flex flex-col gap-4">
183+ <div>
184+ <h4 className="font-bold pb-4">Select your video device:</h4>
185+ {availableCameras.map((c) => {
186+ return (
187+ <label key={c.id} className="flex flex-row gap-2">
188+ <input
189+ type="radio"
190+ name="selected-camera"
191+ value={c.id}
192+ checked={c.id === selectedCameraId}
193+ onChange={(e) => {
194+ const id = e.target.value;
195+ setSelectedCameraId(id);
196+ }}
197+ />
198+ <div>{c.label}</div>
199+ </label>
200+ );
201+ })}
202+ </div>
203+
204+ <div>
205+ <h4 className="font-bold pb-4">Blur your background?</h4>
206+ <div className="flex flex-row justify-center">
207+ <button onClick={handleBlurBackground}>
208+ <SecondaryButton>
209+ <p className="px-4 py-2">Yes</p>
210+ </SecondaryButton>
211+ </button>
212+ </div>
213+ </div>
214+
215+ <div className="text-center">
216+ <button onClick={() => setShowSettingsModal(false)}>
217+ <PrimaryButton>
218+ <p className="px-4 py-2">Close</p>
219+ </PrimaryButton>
220+ </button>
221+ </div>
222+ </div>
223+ </Modal>
224+
203225 {otherHosts.map((host) => {
204- console.log(host);
205226 return (
206227 <div
207228 key={host.uid}