Compare commits
14 Commits
mrt-rework
...
revert-148
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2c2eca6084 | ||
|
|
0429d8b770 | ||
|
|
7175f6571e | ||
|
|
614b92325e | ||
|
|
b5d67e55b4 | ||
|
|
ea9c2c0f38 | ||
|
|
72c214a189 | ||
|
|
022d20356c | ||
|
|
228b0617e6 | ||
|
|
3413f74fcd | ||
|
|
bfe4d56cf7 | ||
|
|
b1e508ef36 | ||
|
|
6e8884f3fb | ||
|
|
dde52bde39 |
@@ -1,13 +1,27 @@
|
||||
import { useEffect } from "react"; // ...existing code...
|
||||
import { useMrtStore } from "_store/pilot/MrtStore";
|
||||
import Image from "next/image";
|
||||
import DAY_BASE_IMG from "./images/Base_NoScreen_Day.png";
|
||||
import NIGHT_BASE_IMG from "./images/Base_NoScreen_Night.png";
|
||||
|
||||
export const MrtBase = () => {
|
||||
const { nightMode } = useMrtStore((state) => state);
|
||||
const { nightMode, setNightMode, page } = useMrtStore((state) => state);
|
||||
|
||||
useEffect(() => {
|
||||
const checkNightMode = () => {
|
||||
const currentHour = new Date().getHours();
|
||||
setNightMode(currentHour >= 22 || currentHour < 8);
|
||||
};
|
||||
|
||||
checkNightMode(); // Initial check
|
||||
const intervalId = setInterval(checkNightMode, 60000); // Check every minute
|
||||
|
||||
return () => clearInterval(intervalId); // Cleanup on unmount
|
||||
}, [setNightMode]); // ...existing code...
|
||||
|
||||
return (
|
||||
<Image
|
||||
src={nightMode ? NIGHT_BASE_IMG : DAY_BASE_IMG}
|
||||
src={nightMode && page !== "off" ? NIGHT_BASE_IMG : DAY_BASE_IMG}
|
||||
alt=""
|
||||
className="z-30 col-span-full row-span-full"
|
||||
/>
|
||||
|
||||
@@ -19,7 +19,14 @@ const MrtButton = ({ onClick, onHold, style }: MrtButtonProps) => {
|
||||
|
||||
const handleMouseDown = () => {
|
||||
if (!onHold) return;
|
||||
timeoutRef.current = setTimeout(onHold, 500);
|
||||
timeoutRef.current = setTimeout(handleTimeoutExpired, 500);
|
||||
};
|
||||
|
||||
const handleTimeoutExpired = () => {
|
||||
timeoutRef.current = null;
|
||||
if (onHold) {
|
||||
onHold();
|
||||
}
|
||||
};
|
||||
|
||||
const handleMouseUp = () => {
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
import { SetPageParams, useMrtStore } from "_store/pilot/MrtStore";
|
||||
import Image, { StaticImageData } from "next/image";
|
||||
import PAGE_HOME from "./images/PAGE_Home.png";
|
||||
import PAGE_HOME_NO_GROUP from "./images/PAGE_Home_no_group.png";
|
||||
import PAGE_Call from "./images/PAGE_Call.png";
|
||||
import PAGE_Off from "./images/PAGE_Off.png";
|
||||
import PAGE_STARTUP from "./images/PAGE_Startup.png";
|
||||
@@ -22,7 +23,7 @@ export const MrtDisplay = () => {
|
||||
const callEstablishedRef = useRef(false);
|
||||
const session = useSession();
|
||||
const { connectedAircraft, selectedStation } = usePilotConnectionStore((state) => state);
|
||||
const { room, speakingParticipants, isTalking } = useAudioStore((state) => state);
|
||||
const { room, speakingParticipants, isTalking, state } = useAudioStore((state) => state);
|
||||
const [pageImage, setPageImage] = useState<{
|
||||
src: StaticImageData;
|
||||
name: SetPageParams["page"];
|
||||
@@ -49,7 +50,6 @@ export const MrtDisplay = () => {
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
console.log("speakingParticipants", speakingParticipants, isTalking, page);
|
||||
if ((speakingParticipants.length > 0 || isTalking) && page === "home") {
|
||||
setPage({
|
||||
page: "voice-call",
|
||||
@@ -157,7 +157,11 @@ export const MrtDisplay = () => {
|
||||
|
||||
switch (page) {
|
||||
case "home":
|
||||
setNextImage({ src: PAGE_HOME, name: "home" });
|
||||
if (state == "connected") {
|
||||
setNextImage({ src: PAGE_HOME, name: "home" });
|
||||
} else {
|
||||
setNextImage({ src: PAGE_HOME_NO_GROUP, name: "home" });
|
||||
}
|
||||
break;
|
||||
case "voice-call":
|
||||
setNextImage({ src: PAGE_Call, name: "voice-call" });
|
||||
@@ -169,7 +173,7 @@ export const MrtDisplay = () => {
|
||||
setNextImage({ src: PAGE_STARTUP, name: "startup" });
|
||||
break;
|
||||
}
|
||||
}, [page]);
|
||||
}, [page, state]);
|
||||
|
||||
const DisplayText = ({ pageName }: { pageName: SetPageParams["page"] }) => {
|
||||
return (
|
||||
@@ -204,10 +208,10 @@ export const MrtDisplay = () => {
|
||||
{!connectedAircraft && <>Keine Verbindung</>}
|
||||
</p>
|
||||
<p className="absolute left-[22.7%] top-[37.8%] flex h-[5%] w-[34%] items-center text-xs">
|
||||
{room?.name || "Keine RG gefunden"}
|
||||
{state == "connected" ? room?.name : "Keine RG gewählt"}
|
||||
</p>
|
||||
<p className="absolute left-[28%] top-[44.5%] h-[8%] w-[34%] text-xs">
|
||||
{ROOMS.find((r) => r.name === room?.name)?.id}
|
||||
{state == "connected" && ROOMS.find((r) => r.name === room?.name)?.id}
|
||||
</p>
|
||||
</>
|
||||
)}
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 4.3 MiB |
@@ -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,
|
||||
|
||||
@@ -76,7 +76,6 @@ export const ConnectionBtn = () => {
|
||||
const session = useSession();
|
||||
const uid = session.data?.user?.id;
|
||||
if (!uid) return null;
|
||||
console.log(bookings);
|
||||
return (
|
||||
<div className="rounded-box bg-base-200 flex items-center justify-center gap-2 p-1">
|
||||
{connection.message.length > 0 && (
|
||||
|
||||
@@ -25,8 +25,6 @@ import { ROOMS } from "_data/livekitRooms";
|
||||
|
||||
let interval: NodeJS.Timeout;
|
||||
|
||||
const connectedSound = new Audio("/sounds/403.wav");
|
||||
|
||||
type TalkState = {
|
||||
addSpeakingParticipant: (participant: Participant) => void;
|
||||
connect: (room: (typeof ROOMS)[number] | undefined, role: string) => void;
|
||||
@@ -190,6 +188,7 @@ export const useAudioStore = create<TalkState>((set, get) => ({
|
||||
if (!token) throw new Error("Fehlende Berechtigung");
|
||||
const room = new Room({});
|
||||
await room.prepareConnection(url, token);
|
||||
const roomConnectedSound = new Audio("/sounds/403.wav");
|
||||
room
|
||||
// Connection events
|
||||
.on(RoomEvent.Connected, async () => {
|
||||
@@ -219,7 +218,7 @@ export const useAudioStore = create<TalkState>((set, get) => ({
|
||||
source: Track.Source.Microphone,
|
||||
});
|
||||
await publishedTrack.mute();
|
||||
connectedSound.play().catch((e) => console.error("Fehler beim Abspielen des Sounds", e));
|
||||
roomConnectedSound.play();
|
||||
set({ localRadioTrack: publishedTrack });
|
||||
|
||||
set({ state: "connected", room, isTalking: false, message: null });
|
||||
|
||||
Reference in New Issue
Block a user