fix: 선택약관 4차수정 250622
This commit is contained in:
@@ -25,18 +25,21 @@ let startVideoTimer = null;
|
||||
//start Full -> modal mode
|
||||
let startVideoFocusTimer = null;
|
||||
export const startVideoPlayer =
|
||||
({ modal, modalContainerId, modalClassName, spotlightDisable, ...rest }) =>
|
||||
({ modal, modalContainerId, modalClassName, spotlightDisable, useNewPlayer, ...rest }) =>
|
||||
(dispatch, getState) => {
|
||||
const panels = getState().panels.panels;
|
||||
const topPanel = panels[panels.length - 1];
|
||||
let panelWorkingAction = pushPanel;
|
||||
if (topPanel && topPanel.name === panel_names.PLAYER_PANEL) {
|
||||
|
||||
const panelName = useNewPlayer ? panel_names.PLAYER_PANEL_NEW : panel_names.PLAYER_PANEL;
|
||||
|
||||
if (topPanel && topPanel.name === panelName) {
|
||||
panelWorkingAction = updatePanel;
|
||||
}
|
||||
dispatch(
|
||||
panelWorkingAction(
|
||||
{
|
||||
name: panel_names.PLAYER_PANEL,
|
||||
name: panelName,
|
||||
panelInfo: {
|
||||
modal,
|
||||
modalContainerId,
|
||||
@@ -116,3 +119,52 @@ export const getSubTitle =
|
||||
export const CLEAR_PLAYER_INFO = () => ({
|
||||
type: types.CLEAR_PLAYER_INFO,
|
||||
});
|
||||
|
||||
/**
|
||||
* 비디오 재생 제어권을 요청하는 액션.
|
||||
* 컴포넌트가 비디오를 재생하고 싶을 때 이 액션을 호출합니다.
|
||||
* 'playerControl' 상태를 확인하여 현재 다른 컴포넌트가 비디오를 제어하고 있지 않은 경우에만
|
||||
* 비디오 플레이어를 활성화(PlayerPanel을 modal로 push)합니다.
|
||||
*
|
||||
* @param {string} ownerId - 비디오 제어권을 요청하는 컴포넌트의 고유 ID.
|
||||
* @param {object} videoInfo - 'startVideoPlayer'에 필요한 비디오 정보.
|
||||
*/
|
||||
export const requestPlayControl =
|
||||
(ownerId, videoInfo) => (dispatch, getState) => {
|
||||
const { playerControl } = getState().home;
|
||||
const currentOwnerId = playerControl.ownerId;
|
||||
|
||||
// 이미 다른 컴포넌트가 제어권을 가지고 있다면, 먼저 해제한다. (선점)
|
||||
if (currentOwnerId && currentOwnerId !== ownerId) {
|
||||
dispatch(releasePlayControl(currentOwnerId, true)); // fromPreemption = true
|
||||
}
|
||||
|
||||
// 새로운 제어권을 설정하고 비디오를 재생한다.
|
||||
dispatch({
|
||||
type: types.SET_PLAYER_CONTROL,
|
||||
payload: { ownerId },
|
||||
});
|
||||
dispatch(startVideoPlayer({ ...videoInfo, modal: true }));
|
||||
};
|
||||
|
||||
/**
|
||||
* 비디오 재생 제어권을 해제하는 액션.
|
||||
* 컴포넌트가 비디오 재생을 중단할 때(예: 포커스 잃음, 언마운트) 호출합니다.
|
||||
* 현재 제어권을 가진 컴포넌트가 자신일 경우에만 'playerControl' 상태를 초기화하고
|
||||
* 비디오 플레이어를 종료(PlayerPanel을 pop)합니다.
|
||||
*
|
||||
* @param {string} ownerId - 비디오 제어권을 해제하려는 컴포넌트의 고유 ID.
|
||||
* @param {boolean} fromPreemption - 다른 요청에 의해 강제로 해제되었는지 여부.
|
||||
*/
|
||||
export const releasePlayControl = (ownerId, fromPreemption = false) => (dispatch, getState) => {
|
||||
const { playerControl } = getState().home;
|
||||
|
||||
// 제어권을 가진 컴포넌트가 자신일 경우에만 해제
|
||||
// 단, 선점 로직에 의해 호출된 경우는 소유권 확인 없이 즉시 실행
|
||||
if (fromPreemption || playerControl.ownerId === ownerId) {
|
||||
dispatch({
|
||||
type: types.CLEAR_PLAYER_CONTROL,
|
||||
});
|
||||
dispatch(finishVideoPreview());
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user