Skip to content

Commit

Permalink
Merge pull request #195 from boostcampwm-2024/feature/#191
Browse files Browse the repository at this point in the history
[Feat] ๋น„๋””์˜ค / ์˜ค๋””์˜ค ํ…Œ์ŠคํŠธ ๊ธฐ๋Šฅ ์ถ”๊ฐ€
  • Loading branch information
zizonyoungjun authored Nov 28, 2024
2 parents 16e0cc9 + 45ae825 commit 5852b32
Show file tree
Hide file tree
Showing 12 changed files with 70 additions and 67 deletions.
4 changes: 2 additions & 2 deletions packages/frontend/src/assets/images/CameraOff.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 3 additions & 2 deletions packages/frontend/src/assets/images/CameraOn.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions packages/frontend/src/assets/images/MikeOff.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions packages/frontend/src/assets/images/MikeOn.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import CameraSettingButton from '@/components/gamePage/rightSection/CameraSettingButton';
import MikeSettingButton from '@/components/gamePage/rightSection/MikeSettingButton';
import CameraSettingButton from '@/components/gamePage/stream/CameraSettingButton';
import MikeSettingButton from '@/components/gamePage/stream/MikeSettingButton';
import LeaveButton from '@/components/gamePage/rightSection/LeaveButton';

export default function SettingSection() {
return (
<div className="flex justify-around p-4 bg-black rounded-lg opacity-80">
<MikeSettingButton />
<CameraSettingButton />
<MikeSettingButton iconColor="text-white-default" />
<CameraSettingButton iconColor="text-white-default" />
<LeaveButton />
</div>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import CameraOn from '@/assets/images/CameraOn.svg?react';
import CameraOff from '@/assets/images/CameraOff.svg?react';
import { useLocalStreamStore } from '@/states/store/localStreamStore';

export default function CameraSettingButton() {
export default function CameraSettingButton({ iconColor }: { iconColor: string }) {
const { localStream } = useLocalStreamStore();
const [isCameraOn, setIsCameraOn] = useState(false);
function handleCamera() {
Expand All @@ -12,20 +12,16 @@ export default function CameraSettingButton() {
if (camera) camera.enabled = !isCameraOn;
}
useEffect(() => {
const initSetting = !!localStream?.getVideoTracks()[0];
const initSetting = !!localStream?.getVideoTracks()[0].enabled;
setIsCameraOn(initSetting);
}, [localStream]);
return (
<button
className="p-4 w-[120px] bg-transparent rounded-lg flex flex-col items-center justify-center gap-2"
onClick={handleCamera}
>
{isCameraOn ? (
<CameraOn className="text-white-default" />
) : (
<CameraOff className="text-white-default" />
)}
<p className="text-white-default text-lg">
{isCameraOn ? <CameraOn className={iconColor} /> : <CameraOff className={iconColor} />}
<p className={`text-lg ${iconColor}`}>
์นด๋ฉ”๋ผ {isCameraOn ? <span className="text-red-600">ON</span> : <span>OFF</span>}
</p>
</button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import MikeOn from '@/assets/images/MikeOn.svg?react';
import MikeOff from '@/assets/images/MikeOff.svg?react';
import { useLocalStreamStore } from '@/states/store/localStreamStore';

export default function MikeSettingButton() {
export default function MikeSettingButton({ iconColor }: { iconColor: string }) {
const { localStream } = useLocalStreamStore();
const [isMikeOn, setIsMikeOn] = useState(false);
function handleMike() {
Expand All @@ -12,20 +12,16 @@ export default function MikeSettingButton() {
if (mike) mike.enabled = !isMikeOn;
}
useEffect(() => {
const initSetting = !!localStream?.getAudioTracks()[0];
const initSetting = !!localStream?.getAudioTracks()[0].enabled;
setIsMikeOn(initSetting);
}, [localStream]);
return (
<button
className="w-[120px] p-4 bg-transparent rounded-lg flex flex-col items-center justify-center gap-2"
className="w-[120px] p-4 bg-transparent rounded-lg flex flex-col items-center justify-center gap-2 text-black"
onClick={handleMike}
>
{isMikeOn ? (
<MikeOn className="text-white-default" />
) : (
<MikeOff className="text-white-default" />
)}
<p className="text-white-default text-lg">
{isMikeOn ? <MikeOn className={iconColor} /> : <MikeOff className={iconColor} />}
<p className={`text-lg ${iconColor}`}>
๋งˆ์ดํฌ {isMikeOn ? <span className="text-red-600">ON</span> : <span>OFF</span>}
</p>
</button>
Expand Down
25 changes: 0 additions & 25 deletions packages/frontend/src/components/lobbyPage/SettingSection.tsx

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
import Button from '@/components/common/Button';
import VideoAudioTestModal from '@/components/lobbyPage/VideoAudioTestModal';
import { useState } from 'react';

export default function VideoAudioTestButton() {
function handleClick() {}
const [isModalOpen, setIsModalOpen] = useState(false);
const title = '๋น„๋””์˜ค ๋ฐ ์˜ค๋””์˜ค ํ…Œ์ŠคํŠธ';
function handleClick() {
setIsModalOpen(true);
}
return (
<Button
className="w-full h-20 text-xl font-semibold text-black bg-white hover:bg-gray-300"
onClick={handleClick}
buttonText="๋น„๋””์˜ค ๋ฐ ์˜ค๋””์˜ค ํ…Œ์ŠคํŠธ"
/>
<>
<Button
className="w-full h-20 text-xl font-semibold text-black bg-white hover:bg-gray-300"
onClick={handleClick}
buttonText={title}
/>
{isModalOpen && <VideoAudioTestModal title={title} onClose={() => setIsModalOpen(false)} />}
</>
);
}
31 changes: 31 additions & 0 deletions packages/frontend/src/components/lobbyPage/VideoAudioTestModal.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import VideoStream from '@/components/gamePage/stream/VideoStream';
import { useLocalStreamStore } from '@/states/store/localStreamStore';
import CameraSettingButton from '@/components/gamePage/stream/CameraSettingButton';
import MikeSettingButton from '@/components/gamePage/stream/MikeSettingButton';

interface IVideoAudioTestModalProps {
onClose: () => void;
title: string;
}

export default function VideoAudioTestModal({ onClose, title }: IVideoAudioTestModalProps) {
const localStream = useLocalStreamStore((state) => state.localStream);
return (
<div className="fixed inset-0 z-50 flex flex-col items-center justify-center bg-black bg-opacity-50">
<div className="min-w-[600px] max-w-lg p-8 bg-white shadow-lg rounded-2xl flex flex-col items-center gap-8">
<h2 className="mb-4 text-xl font-semibold text-center text-gray-900">{title}</h2>
<VideoStream userName="์นด๋ฉ”๋ผ ํ…Œ์ŠคํŠธ" stream={localStream} />
<div className="flex gap-4">
<CameraSettingButton iconColor="text-black" />
<MikeSettingButton iconColor="text-black" />
</div>
<button
onClick={onClose}
className="w-32 py-2 text-black border border-black rounded-lg hover:bg-gray-100"
>
๋‹ซ๊ธฐ
</button>
</div>
</div>
);
}
5 changes: 0 additions & 5 deletions packages/frontend/src/pages/lobbyPage/index.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import { useEffect } from 'react';
import { useSocketStore } from '@/states/store/socketStore';
import { useAuthStore } from '@/states/store/authStore';
import BackgroundImage from '@/components/layout/BackgroundImage';
import MainLogo from '@/assets/images/MainLogo.svg?react';
import RoomCreationButton from '@/components/lobbyPage/RoomCreationButton';
import RoomJoinButton from '@/components/lobbyPage/RoomJoinButton';
import VideoAudioTestButton from '@/components/lobbyPage/VideoAudioTestButton';
import Header from '@/components/layout/Header';
import SettingSection from '@/components/lobbyPage/SettingSection';
import { useRoomStore } from '@/states/store/roomStore';
import { useChatStore } from '@/states/store/chatStore';
import { useLocalStreamStore } from '@/states/store/localStreamStore';
Expand Down Expand Up @@ -50,9 +48,6 @@ export default function LobbyPage() {
<RoomCreationButton />
<RoomJoinButton />
</div>
<div className="absolute flex justify-end w-full bottom-10">
<SettingSection />
</div>
</div>
</>
);
Expand Down
4 changes: 2 additions & 2 deletions packages/frontend/src/states/store/signalingSocketStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export const useSignalingSocketStore = create<ISignalingSocketStore>((set, get)

signalingSocket.on('user_joined', async ({ fromUserId, gsid }) => {
console.log('[Client][๐Ÿ“ข] user_joined', fromUserId, gsid);
const localStream = await getVideoStream();
const localStream = useLocalStreamStore.getState().localStream;
const { setRemoteStream } = usePeerConnectionStore.getState();
const peerConnection = createPeerConnection({
fromUserId,
Expand Down Expand Up @@ -85,7 +85,7 @@ export const useSignalingSocketStore = create<ISignalingSocketStore>((set, get)
});

signalingSocket.on('video_offer', async ({ offer, fromUserId, gsid }) => {
const localStream = await getVideoStream();
const localStream = useLocalStreamStore.getState().localStream;
const { setRemoteStream } = usePeerConnectionStore.getState();
const peerConnection = createPeerConnection({
fromUserId,
Expand Down

0 comments on commit 5852b32

Please sign in to comment.