[PlayerPanel] percent 게이지 실시간 감지 기능
This commit is contained in:
@@ -50,33 +50,36 @@ export default memo(function PlayerItemCard({
|
|||||||
videoVerticalVisible,
|
videoVerticalVisible,
|
||||||
currentVideoVisible,
|
currentVideoVisible,
|
||||||
dangerouslySetInnerHTML,
|
dangerouslySetInnerHTML,
|
||||||
|
currentTime,
|
||||||
liveInfo,
|
liveInfo,
|
||||||
|
startDt,
|
||||||
|
endDt,
|
||||||
type = TYPES.liveHorizontal,
|
type = TYPES.liveHorizontal,
|
||||||
|
|
||||||
...rest
|
...rest
|
||||||
}) {
|
}) {
|
||||||
const [focused, setFocused] = useState(false);
|
const [focused, setFocused] = useState(false);
|
||||||
const [percent, setPercent] = useState(0);
|
const [percentGauge, setPercentGauge] = useState(0);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (liveInfo) {
|
if (startDt && endDt) {
|
||||||
const localStartDt = convertUtcToLocal(liveInfo?.strtDt);
|
let localStartDt = convertUtcToLocal(startDt);
|
||||||
const localEndDt = convertUtcToLocal(liveInfo?.endDt);
|
let localEndDt = convertUtcToLocal(endDt);
|
||||||
const curDt = new Date();
|
let curDt = new Date();
|
||||||
const localStartSec = localStartDt?.getTime() / 1000;
|
let localStartSec = localStartDt?.getTime() / 1000;
|
||||||
const localEndSec = localEndDt?.getTime() / 1000;
|
let localEndSec = localEndDt?.getTime() / 1000;
|
||||||
const curSec = curDt?.getTime() / 1000;
|
let curSec = curDt?.getTime() / 1000;
|
||||||
const fullSec = localEndSec - localStartSec;
|
let fullSec = localEndSec - localStartSec;
|
||||||
const diff = curSec - localStartSec;
|
let diff = curSec - localStartSec;
|
||||||
|
|
||||||
let percent = Math.floor((diff * 100) / fullSec);
|
let percent = Math.floor((diff * 100) / fullSec);
|
||||||
|
|
||||||
if (percent > 100) {
|
if (percent > 100) {
|
||||||
percent = 100;
|
percent = 0;
|
||||||
}
|
}
|
||||||
setPercent(percent);
|
setPercentGauge(percent);
|
||||||
}
|
}
|
||||||
}, [liveInfo]);
|
}, [startDt, endDt, currentTime, percentGauge]);
|
||||||
|
|
||||||
const _onBlur = useCallback(() => {
|
const _onBlur = useCallback(() => {
|
||||||
setFocused(false);
|
setFocused(false);
|
||||||
@@ -105,7 +108,10 @@ export default memo(function PlayerItemCard({
|
|||||||
}
|
}
|
||||||
}, [onFocus]);
|
}, [onFocus]);
|
||||||
|
|
||||||
const progressStyle = useMemo(() => ({ width: `${percent}%` }), [percent]);
|
const progressStyle = useMemo(
|
||||||
|
() => ({ width: `${percentGauge}%` }),
|
||||||
|
[percentGauge]
|
||||||
|
);
|
||||||
const ariaLabel = "Selected, " + patnerName + " " + productName();
|
const ariaLabel = "Selected, " + patnerName + " " + productName();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ export default function TabContainer({
|
|||||||
featuredShowsInfos,
|
featuredShowsInfos,
|
||||||
handleItemFocus,
|
handleItemFocus,
|
||||||
prevChannelIndex,
|
prevChannelIndex,
|
||||||
|
currentTime,
|
||||||
}) {
|
}) {
|
||||||
const [tab, setTab] = useState(0);
|
const [tab, setTab] = useState(0);
|
||||||
|
|
||||||
@@ -147,6 +148,7 @@ export default function TabContainer({
|
|||||||
liveInfos={playListInfo}
|
liveInfos={playListInfo}
|
||||||
tabIndex={tab}
|
tabIndex={tab}
|
||||||
handleItemFocus={_handleItemFocus}
|
handleItemFocus={_handleItemFocus}
|
||||||
|
currentTime={currentTime}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import css from "./LiveChannelContents.module.less";
|
|||||||
|
|
||||||
export default function LiveChannelContents({
|
export default function LiveChannelContents({
|
||||||
liveInfos,
|
liveInfos,
|
||||||
|
currentTime,
|
||||||
setSelectedIndex,
|
setSelectedIndex,
|
||||||
videoVerticalVisible,
|
videoVerticalVisible,
|
||||||
tabIndex,
|
tabIndex,
|
||||||
@@ -89,10 +90,13 @@ export default function LiveChannelContents({
|
|||||||
type={TYPES.liveHorizontal}
|
type={TYPES.liveHorizontal}
|
||||||
spotlightId={`tabChannel-video-${index}`}
|
spotlightId={`tabChannel-video-${index}`}
|
||||||
liveInfo={liveInfos[index]}
|
liveInfo={liveInfos[index]}
|
||||||
|
startDt={strtDt}
|
||||||
|
endDt={endDt}
|
||||||
|
currentTime={currentTime}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
[liveInfos, dispatch, handleFocus]
|
[liveInfos, currentTime, dispatch, handleFocus]
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
Reference in New Issue
Block a user