fixed Sound nach Verbinden auf RG

This commit is contained in:
PxlLoewe
2026-01-15 22:22:36 +01:00
parent 022d20356c
commit 72c214a189
2 changed files with 19 additions and 3 deletions

View File

@@ -1,7 +1,10 @@
"use client";
import { useAudioStore } from "_store/audioStore";
import { RoomEvent } from "livekit-client";
import { useEffect, useRef } from "react";
export const useSounds = () => {
const { room } = useAudioStore((state) => state);
const longBtnPressSoundRef = useRef<HTMLAudioElement>(null);
const statusSentSoundRef = useRef<HTMLAudioElement>(null);
const sdsReceivedSoundRef = useRef<HTMLAudioElement>(null);
@@ -14,6 +17,20 @@ export const useSounds = () => {
}
}, []);
useEffect(() => {
const handleRoomConnected = () => {
// Play a sound when connected to the room
// connectedSound.play();
statusSentSoundRef.current?.play();
console.log("Room connected - played sound");
};
room?.on(RoomEvent.Connected, handleRoomConnected);
return () => {
room?.off(RoomEvent.Connected, handleRoomConnected);
};
}, [room]);
return {
longBtnPressSoundRef,
statusSentSoundRef,