fixed force end call
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
"use client";
|
||||
import { useDebounce } from "_helpers/useDebounce";
|
||||
import { useAudioStore } from "_store/audioStore";
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
|
||||
export const useSounds = ({
|
||||
@@ -11,6 +12,7 @@ export const useSounds = ({
|
||||
isTransmitting: boolean;
|
||||
unpausedTracks: unknown[];
|
||||
}) => {
|
||||
const { room } = useAudioStore();
|
||||
// Sounds as refs
|
||||
const connectionStart = useRef<HTMLAudioElement | null>(null);
|
||||
const connectionEnd = useRef<HTMLAudioElement | null>(null);
|
||||
@@ -70,10 +72,10 @@ export const useSounds = ({
|
||||
}
|
||||
}, [isReceiving]);
|
||||
|
||||
// Hotmic warning after 30 seconds
|
||||
// Hotmic warning after 25 seconds
|
||||
useEffect(() => {
|
||||
if (isTransmitting) {
|
||||
const timeout = setTimeout(() => {
|
||||
const soundsTimeout = setTimeout(() => {
|
||||
if (isTransmitting) {
|
||||
callToLong.current!.loop = true;
|
||||
callToLong.current!.currentTime = 0;
|
||||
@@ -81,8 +83,19 @@ export const useSounds = ({
|
||||
callToLong.current!.play();
|
||||
}
|
||||
}, 25000);
|
||||
const forceEndTransmitionTimeout = setTimeout(() => {
|
||||
if (isTransmitting) {
|
||||
room?.localParticipant.setMicrophoneEnabled(false);
|
||||
useAudioStore.setState({
|
||||
isTalking: false,
|
||||
message: "Hotmic erkannt! Ruf wurde beendet.",
|
||||
});
|
||||
}
|
||||
}, 25000 + 10000);
|
||||
|
||||
return () => {
|
||||
clearTimeout(timeout);
|
||||
clearTimeout(soundsTimeout);
|
||||
clearTimeout(forceEndTransmitionTimeout);
|
||||
callToLong.current!.pause();
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user