Skip to content

Commit

Permalink
Merge pull request #102 from SWM-FIRE/FIRE-411-방에-접속하면-해당하는-화이트-노이즈가-나온다
Browse files Browse the repository at this point in the history
Fire 411 방에 접속하면 해당하는 화이트 노이즈가 나온다
  • Loading branch information
071yoon authored Aug 8, 2022
2 parents acf96e1 + d9fd92e commit a460f54
Show file tree
Hide file tree
Showing 9 changed files with 56 additions and 5 deletions.
Binary file added src/assets/sound/camping.mp3
Binary file not shown.
Binary file added src/assets/sound/cosmos.mp3
Binary file not shown.
Binary file added src/assets/sound/fire.mp3
Binary file not shown.
Binary file added src/assets/sound/ocean.mp3
Binary file not shown.
Binary file added src/assets/sound/travel.mp3
Binary file not shown.
15 changes: 14 additions & 1 deletion src/components/room/Theme.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,31 @@
import { useState } from 'react';
import { useState, useRef, useEffect } from 'react';
import styled from 'styled-components';
import MovingTheme from './screenShare/MovingTheme';
import { ReactComponent as VolumeOn } from '../../assets/svg/VolumeOn.svg';
import { ReactComponent as VolumeOff } from '../../assets/svg/VolumeOff.svg';
import UserMediaStreamStore from '../../stores/userMediaStreamStore';
import ThemeSound from './header/ThemeSound';

export default function Theme({ theme }) {
const { userSpeaker, setUserSpeaker } = UserMediaStreamStore();
const [volume, setVolume] = useState<number>(0.5);
const volumeRef = useRef<HTMLAudioElement>(null);
const setSpeaker = () => {
setUserSpeaker();
};
useEffect(() => {
if (!userSpeaker) {
volumeRef.current.volume = 0;
return;
}
if (volumeRef.current) {
volumeRef.current.volume = volume;
}
}, [volume, userSpeaker]);

return (
<Container>
<ThemeSound volumeRef={volumeRef} theme={theme} />
<MovingTheme theme={theme} size="3.2" />
<Volume onClick={setSpeaker}>
{userSpeaker && volume !== 0 ? <VolumeOn /> : <VolumeOff />}
Expand Down
37 changes: 37 additions & 0 deletions src/components/room/header/ThemeSound.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import campingOST from '../../../assets/sound/camping.mp3';
import cosmosOST from '../../../assets/sound/cosmos.mp3';
import fireOST from '../../../assets/sound/fire.mp3';
import oceanOST from '../../../assets/sound/ocean.mp3';
import travelOST from '../../../assets/sound/travel.mp3';

export default function ThemeSound({ theme, volumeRef }) {
console.log('sound theme', theme);

let myTheme;
switch (theme) {
case 'fire':
myTheme = fireOST;
break;
case 'ocean':
myTheme = oceanOST;
break;
case 'camping':
myTheme = campingOST;
break;
case 'cosmos':
myTheme = cosmosOST;
break;
case 'travel':
myTheme = travelOST;
break;
default:
myTheme = fireOST;
break;
}

return (
<audio ref={volumeRef} src={myTheme} autoPlay loop>
<track kind="captions" />
</audio>
);
}
1 change: 1 addition & 0 deletions src/custom.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ declare module '*.svg' {
export default src;
}
declare module '*.gif';
declare module '*.mp3';
8 changes: 4 additions & 4 deletions src/pages/Room.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,20 @@ export default function Room() {

if (error) return <div>An error has occurred: </div>;

const onCotrolSidebarClick = () => {
const onControlSidebarClick = () => {
openSidebar();
};

return (
<ThemeProvider theme={theme}>
<Component>
<Header theme={theme} />
<Header theme={data?.theme} />
<Contents>
<ScreenShare theme={theme} />
<ScreenShare theme={data?.theme} />
{!isOpenSidebar && (
<ControlSidebar
backgroundColor={theme.chatBackground}
onClick={onCotrolSidebarClick}
onClick={onControlSidebarClick}
>
<LeftTwoArrows />
<Chatting />
Expand Down

0 comments on commit a460f54

Please sign in to comment.