면접자의 영상을 스트리밍, 재생하는 컴포넌트
Video 태그 기본 형태를 따름
| Parameter | Type | Require | |
|---|---|---|---|
| src | **string | MediaStream** | O |
| width | number | ||
| height | number | ||
| autoplay | boolean | ||
| controls | boolean | ||
| muted | boolean |
import React, { useRef, useEffect } from 'react';
import { useRecoilState } from 'recoil';
import Video, { VideoPropType } from '@components/@shared/Video/Video';
import { currentTimeState } from '@store/feedbackStore';
const IntervieweeVideo = (props: VideoPropType) => {
const [currentTime, setCurrentTime] = useRecoilState(currentTimeState);
const videoRef = useRef<HTMLVideoElement>(null);
const sendPeriod = 1000;
const sendCurrentTime = () => {
if (!videoRef.current?.currentTime) return;
const currentTime = videoRef.current.currentTime;
setCurrentTime(currentTime);
};
useEffect(() => {
if (videoRef) {
const intervalId = setInterval(sendCurrentTime, sendPeriod);
return () => clearInterval(intervalId);
}
}, []);
useEffect(() => {
if (videoRef) {
videoRef.current.currentTime = currentTime;
console.log(currentTime);
}
}, [currentTime]);
return <Video {...props} ref={videoRef} />;
};
export default IntervieweeVideo;
| 이름 | 설명 |
|---|---|
| Default | 일반 영상 파일 재생 |
| MediaStream | 스트리밍 영상 재생 |
갱신 필요