-
Notifications
You must be signed in to change notification settings - Fork 0
Feat(#209, #240) 다시보기 페이지 프로그래스바 및 프롬프트 기능 구현 #241
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
Merged
Jw705
merged 6 commits into
boostcampwm2023:dev
from
Byeonjin:feature/231209-progress-bar
Dec 10, 2023
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
0455622
feat: <video> 태그 <canvas>로 변경
Byeonjin 2469060
feat: 클릭 시 프로그래스 바 이동 후 진행시간 state 변경 #209
Byeonjin c8d525f
feat: 프로그래스 바 클릭 처리 MouseUp으로 이벤트 변경
Byeonjin 218b6e0
- 프로그래스 바 시간 연동 #209
Byeonjin 33e7e38
feat: 재생/정지버튼 기능 구현 #209
Byeonjin 723cdb7
feat: 프로그레스 바와 프롬프트 기능 연결 #240
Byeonjin 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 hidden or 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or 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 hidden or 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,39 +1,68 @@ | ||
import { useSetRecoilState, useRecoilValue } from "recoil"; | ||
import { useRecoilValue } from "recoil"; | ||
import { useEffect, useRef } from "react"; | ||
import { fabric } from "fabric"; | ||
|
||
import CloseIcon from "@/assets/svgs/close.svg?react"; | ||
import ScriptIcon from "@/assets/svgs/whiteboard/script.svg?react"; | ||
|
||
import isQuestionLogOpenState from "@/stores/stateIsQuestionLogOpen"; | ||
import videoRefState from "../Test/components/stateVideoRef"; | ||
|
||
import LogToggleButton from "@/components/Button/LogToggleButton"; | ||
import LogContainer from "@/components/LogContainer/LogContainer"; | ||
import Header from "@/components/Header/Header"; | ||
import ProgressBar from "./components/ProgressBar"; | ||
|
||
// 추후 해당 다시보기의 전체 플레이 타임을 받아올 수 있어야 할 것 같습니다. | ||
const TOTAL_MS_TIME_OF_REVIEW = 200000; | ||
Comment on lines
+15
to
+16
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. 서버에 요청해서 받아오거나 음성 파일 길이로 계산해볼 수 있겠네요! |
||
|
||
const Review = () => { | ||
const setVideoRef = useSetRecoilState(videoRefState); | ||
const videoRef = useRef<HTMLVideoElement>(null); | ||
const canvasRef = useRef<HTMLCanvasElement>(null); | ||
const canvasContainerRef = useRef<HTMLDivElement>(null); | ||
const isQuestionLogOpen = useRecoilValue(isQuestionLogOpenState); | ||
|
||
useEffect(() => { | ||
setVideoRef(videoRef); | ||
if (!canvasContainerRef.current || !canvasRef.current) return; | ||
|
||
const canvasContainer = canvasContainerRef.current; | ||
// 캔버스 생성 | ||
const newCanvas = new fabric.Canvas(canvasRef.current, { | ||
width: canvasContainer.offsetWidth, | ||
height: canvasContainer.offsetHeight, | ||
selection: false | ||
}); | ||
newCanvas.backgroundColor = "lightgray"; | ||
newCanvas.defaultCursor = "default"; | ||
|
||
var text = new fabric.Text("화이트보드를 불러오고 있습니다", { | ||
fontSize: 18, | ||
textAlign: "center", | ||
originX: "center", | ||
originY: "center", | ||
left: canvasContainer.offsetWidth / 2, | ||
top: canvasContainer.offsetHeight / 2, | ||
selectable: false | ||
}); | ||
newCanvas.add(text); | ||
|
||
// 언마운트 시 캔버스 정리 | ||
return () => { | ||
newCanvas.dispose(); | ||
}; | ||
}, []); | ||
|
||
return ( | ||
<> | ||
<Header type="review" /> | ||
<section className="relative"> | ||
<video className="w-[100vw] h-[calc(100vh-5rem)]" autoPlay muted ref={videoRef}></video> | ||
<section className="relative w-screen h-[calc(100vh-5rem)]" ref={canvasContainerRef}> | ||
<canvas className="-z-10" ref={canvasRef} /> | ||
<LogContainer | ||
type="prompt" | ||
className={`absolute top-2.5 right-2.5 ${isQuestionLogOpen ? "block" : "hidden"}`} | ||
/> | ||
<LogToggleButton className="absolute top-2.5 right-2.5"> | ||
{isQuestionLogOpen ? <CloseIcon /> : <ScriptIcon fill="black" />} | ||
</LogToggleButton> | ||
<ProgressBar className="absolute bottom-2.5 left-1/2 -translate-x-1/2" /> | ||
<ProgressBar className="absolute bottom-2.5 left-1/2 -translate-x-1/2" totalTime={TOTAL_MS_TIME_OF_REVIEW} /> | ||
</section> | ||
</> | ||
); | ||
|
This file contains hidden or 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 hidden or 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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { atom } from "recoil"; | ||
|
||
const progressMsTimeState = atom<number>({ | ||
key: "progressMsTimeState", | ||
default: 0 | ||
}); | ||
|
||
export default progressMsTimeState; |
This file contains hidden or 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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
const MS_OF_SECOND = 1000; | ||
const MS_OF_MINUTE = 60 * MS_OF_SECOND; | ||
const MS_OF_HOUR = 60 * MS_OF_MINUTE; | ||
Comment on lines
+1
to
+3
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. 상수 선언 보기 좋습니다! |
||
|
||
const convertTimeStringToMS = (timeString: string) => { | ||
const [hour, minute, second] = timeString.split(":"); | ||
const result = parseInt(hour) * MS_OF_HOUR + parseInt(minute) * MS_OF_MINUTE + parseInt(second) * MS_OF_SECOND; | ||
|
||
return result; | ||
}; | ||
|
||
export default convertTimeStringToMS; |
This file contains hidden or 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.
가능하면 아래 선언한 상수를 활용해서 이 부분도 매직넘버를 사용하지 않도록 고치면 좋을 것 같습니다.