🕐 커밋 시간: 2025. 11. 18. 09:44:39 📊 변경 통계: • 총 파일: 7개 • 추가: +23줄 • 삭제: -23줄 📝 수정된 파일: ~ com.twin.app.shoptime/src/actions/playActions.js ~ com.twin.app.shoptime/src/components/VideoPlayer/VideoPlayer.v3.js ~ com.twin.app.shoptime/src/hooks/useVideoTransition/useVideoMove.bak.js ~ com.twin.app.shoptime/src/hooks/useVideoTransition/useVideoMove.original.js ~ com.twin.app.shoptime/src/views/HomePanel/HomeBanner/RandomUnit.jsx ~ com.twin.app.shoptime/src/views/HomePanel/HomePanel.jsx ~ com.twin.app.shoptime/src/views/PlayerPanel/PlayerPanel.jsx 🔧 주요 변경 내용: • 핵심 비즈니스 로직 개선 • UI 컴포넌트 아키텍처 개선 • 소규모 기능 개선 • 코드 정리 및 최적화 • 모듈 구조 개선
69 lines
2.0 KiB
JavaScript
69 lines
2.0 KiB
JavaScript
import { useRef } from 'react';
|
|
import fp from '../../utils/fp.js';
|
|
import { useVideoPlay } from '../useVideoPlay/useVideoPlay';
|
|
|
|
const useVideoMove = (options = {}) => {
|
|
const { enableLogging = false, logPrefix = '[useVideoMove]' } = options;
|
|
|
|
const { playVideo, restartVideo } = useVideoPlay(options);
|
|
|
|
const log = (message) => enableLogging && console.log(`${logPrefix} ${message}`);
|
|
|
|
const timerRef = useRef(null);
|
|
|
|
const playByTransition = (queue = []) => {
|
|
log(`playByTransition 시작: queue = ${JSON.stringify(queue)}`);
|
|
const q = fp.defaultTo([])(queue);
|
|
|
|
if (q.length === 0) {
|
|
log('빈 큐: Promise.resolve 반환');
|
|
return Promise.resolve();
|
|
}
|
|
|
|
if (q[0] === 'banner0' || q[0] === 'banner1') {
|
|
timerRef.current = setTimeout(() => {
|
|
if (window.restoreVideoSize) {
|
|
window.restoreVideoSize();
|
|
}
|
|
}, 1000);
|
|
log(`banner0/1 케이스: playVideo(${q[0]}) 호출`);
|
|
return playVideo(q[0]);
|
|
} else if (q[0] === 'banner2' || q[0] === 'banner3') {
|
|
if (q[1] === 'banner0' || q[1] === 'banner1') {
|
|
log(`banner2/3 → banner0/1: 동영상 유지 (재생하지 않음)`);
|
|
return Promise.resolve(); // 동영상 유지
|
|
} else if (q[1] === 'icons') {
|
|
log(`icons → banner2/3: restartVideo 호출 (${q[0]})`);
|
|
timerRef.current = setTimeout(() => {
|
|
if (window.restoreVideoSize) {
|
|
window.restoreVideoSize();
|
|
}
|
|
}, 1000);
|
|
return restartVideo();
|
|
}
|
|
} else if (q[0] === 'icons') {
|
|
log('icons 케이스: 비디오 숨김 (소리 유지)');
|
|
|
|
if (window.hideModalVideo) {
|
|
window.hideModalVideo();
|
|
}
|
|
return Promise.resolve(true);
|
|
}
|
|
|
|
log('기본 케이스: Promise.resolve 반환');
|
|
return Promise.resolve();
|
|
};
|
|
|
|
const cleanup = () => {
|
|
// log('cleanup: 타이머 정리');
|
|
if (timerRef.current) {
|
|
clearTimeout(timerRef.current);
|
|
timerRef.current = null;
|
|
}
|
|
};
|
|
|
|
return { playByTransition, cleanup };
|
|
};
|
|
|
|
export { useVideoMove };
|