[SHOPTIME-3440] Full Player / Live / TV Home에 다녀온 이후에 재생 시간 변경 안됨

addEventListener 추가
This commit is contained in:
hyunwoo93.cha
2025-01-13 16:06:30 +09:00
parent b3e1890c9d
commit bfeb4c0fa6

View File

@@ -1253,6 +1253,31 @@ const PlayerPanel = ({
}, [liveShowInfos, selectedIndex, panelInfo.shptmBanrTpNm]);
useEffect(() => {
const handleVisibilityChange = () => {
if (
document.visibilityState === "visible" &&
liveShowInfos &&
panelInfo?.shptmBanrTpNm === "LIVE"
) {
const localStartDt = convertUtcToLocal(
liveShowInfos[selectedIndex]?.strtDt
);
const curDt = new Date();
const localStartSec = localStartDt?.getTime() / 1000;
const curSec = curDt?.getTime() / 1000;
const calculatedLiveTime = curSec - localStartSec;
if (calculatedLiveTime >= liveTotalTime) {
setCurrentLiveTimeSeconds(0);
} else {
setCurrentLiveTimeSeconds(calculatedLiveTime);
}
}
};
document.addEventListener("visibilitychange", handleVisibilityChange);
if (panelInfo.offsetHour) {
setCurrentLiveTimeSeconds(parseInt(panelInfo.offsetHour));
} else if (liveShowInfos && panelInfo?.shptmBanrTpNm === "LIVE") {
@@ -1273,11 +1298,17 @@ const PlayerPanel = ({
} else {
setCurrentLiveTimeSeconds(0);
}
return () => {
document.removeEventListener("visibilitychange", handleVisibilityChange);
};
}, [
liveShowInfos,
selectedIndex,
panelInfo.offsetHour,
panelInfo.shptmBanrTpNm,
playListInfo,
liveTotalTime,
]);
useEffect(() => {