-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat/403: [FE] [녹음] 녹음 시 트랙 재생 관련 인터랙션 막기 #407
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
import { useEffect } from "react"; | ||
import { useRecoilValue } from "recoil"; | ||
|
||
import type { AudioType } from "types/audioType"; | ||
|
||
import { isTrackPlayingState } from "model/audioModel"; | ||
import useRecord from "./useRecord"; | ||
import useTimer from "./useTimer"; | ||
|
||
const useCreateTrack = ({ | ||
inputDeviceId, | ||
|
@@ -16,6 +17,8 @@ const useCreateTrack = ({ | |
onRecordCancel?: () => void; | ||
onTrackRemove?: (audioId: AudioType["id"]) => void; | ||
}) => { | ||
const isTrackPlaying = useRecoilValue(isTrackPlayingState); | ||
|
||
const { | ||
isRecording, | ||
isSuccess: isRecordSuccess, | ||
|
@@ -26,29 +29,31 @@ const useCreateTrack = ({ | |
initRecord, | ||
} = useRecord(inputDeviceId); | ||
|
||
const { start: startTimer, pause: pauseTimer, isExpired, time: timerTime } = useTimer(30); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 이전 로직에서는 녹음 타이머, player 재생을 위한 타이머가 각각 30초씩 동작하고 있었는데, 상태로 관리하다보니 녹음 상태와 Player 재생 상태가 불일치하는 문제가 발생해서 녹음은 트랙 재생 상태에 의존하여 시작하도록 수정했어요. |
||
|
||
const handleRecordButtonClick = () => { | ||
startRecord(); | ||
startTimer(); | ||
}; | ||
|
||
const handleTrackRemove = (audioId: AudioType["id"]) => { | ||
stopRecord(); | ||
pauseTimer(); | ||
|
||
if (window.confirm("녹음된 트랙이 있어요. 정말 삭제할까요?")) { | ||
initRecord(); | ||
onTrackRemove?.(audioId); | ||
} | ||
}; | ||
|
||
// timer가 종료되면 트랙 녹음 중지 | ||
// 녹음 상태이고, track player가 재생상태인 경우에 녹음 시작 | ||
useEffect(() => { | ||
if (isExpired) { | ||
if (!isRecording) { | ||
return; | ||
} | ||
|
||
if (isTrackPlaying) { | ||
startRecord(); | ||
} else { | ||
stopRecord(); | ||
} | ||
}, [isExpired]); | ||
}, [isTrackPlaying]); | ||
|
||
useEffect(() => { | ||
if (isRecordSuccess) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
player 스틱이 마이크 아이콘을 가리지 않도록 투명도를 설정했어요