Alarmieren aus Einsatz erstellen Maske Map-Tiles SDS sound: Status J SDS Nachricht: public-User Audio: Es kann nur ein Nutzer gleichzeitig Funken Select in Report und Chat: default value -> OnChange
54 lines
1.4 KiB
TypeScript
54 lines
1.4 KiB
TypeScript
import { useAudioStore } from "_store/audioStore";
|
|
import {
|
|
LocalParticipant,
|
|
LocalTrackPublication,
|
|
Participant,
|
|
RemoteParticipant,
|
|
RemoteTrack,
|
|
RemoteTrackPublication,
|
|
Track,
|
|
} from "livekit-client";
|
|
|
|
export const handleTrackSubscribed = (
|
|
track: RemoteTrack,
|
|
publication: RemoteTrackPublication,
|
|
participant: RemoteParticipant,
|
|
) => {
|
|
console.log("Track subscribed:", track, publication, participant);
|
|
if (!track.isMuted) {
|
|
useAudioStore.getState().addSpeakingParticipant(participant);
|
|
}
|
|
track.on("unmuted", () => {
|
|
useAudioStore.getState().addSpeakingParticipant(participant);
|
|
});
|
|
track.on("muted", () => {
|
|
useAudioStore.getState().removeSpeakingParticipant(participant);
|
|
});
|
|
if (track.kind === Track.Kind.Video || track.kind === Track.Kind.Audio) {
|
|
// attach it to a new HTMLVideoElement or HTMLAudioElement
|
|
const element = track.attach();
|
|
element.play();
|
|
}
|
|
};
|
|
|
|
export const handleTrackUnsubscribed = (
|
|
track: RemoteTrack,
|
|
publication: RemoteTrackPublication,
|
|
participant: RemoteParticipant,
|
|
) => {
|
|
// remove tracks from all attached elements
|
|
track.detach();
|
|
};
|
|
|
|
export const handleLocalTrackUnpublished = (
|
|
publication: LocalTrackPublication,
|
|
participant: LocalParticipant,
|
|
) => {
|
|
// when local tracks are ended, update UI to remove them from rendering
|
|
publication.track?.detach();
|
|
};
|
|
|
|
export const handleDisconnect = () => {
|
|
console.log("disconnected from room");
|
|
};
|