diff --git a/com.twin.app.shoptime/src/actions/commonActions.js b/com.twin.app.shoptime/src/actions/commonActions.js index ae510040..3ef45bb3 100644 --- a/com.twin.app.shoptime/src/actions/commonActions.js +++ b/com.twin.app.shoptime/src/actions/commonActions.js @@ -296,13 +296,12 @@ export const sendBroadCast = }; export const requestLiveSubtitle = - ({ showId }) => + ({ mediaId, enable }) => (dispatch, getState) => { const webOSVersion = getState().common.appStatus.webOSVersion; - const captionEnable = getState().common.appStatus.captionEnable; if (Number(webOSVersion) <= 4.5) { - lunaSend.setSubtitleEnable(showId, captionEnable, { + lunaSend.setSubtitleEnable(mediaId, enable, { onSuccess: (res) => { console.log(res); }, @@ -312,7 +311,7 @@ export const requestLiveSubtitle = }); return; } else { - lunaSend.setSubtitleEnableOver5(showId, captionEnable, { + lunaSend.setSubtitleEnableOver5(mediaId, enable, { onSuccess: (res) => { console.log(res); }, diff --git a/com.twin.app.shoptime/src/lunaSend/common.js b/com.twin.app.shoptime/src/lunaSend/common.js index 548ff05c..5d6071e1 100644 --- a/com.twin.app.shoptime/src/lunaSend/common.js +++ b/com.twin.app.shoptime/src/lunaSend/common.js @@ -143,7 +143,7 @@ export function checkValidCountry(ricCode, country) { // 3.0 ~ 4.5 export const setSubtitleEnable = ( - showId, + mediaId, captionEnable, { onSuccess, onFailure, onComplete } ) => { @@ -156,7 +156,7 @@ export const setSubtitleEnable = ( return new LS2Request().send({ service: "luna://com.webos.service.tv.subtitle", method: "enableSubtitle", - parameters: { pipelineId: showId }, + parameters: { pipelineId: mediaId }, onSuccess, onFailure, onComplete, @@ -165,7 +165,7 @@ export const setSubtitleEnable = ( return new LS2Request().send({ service: "luna://com.webos.service.tv.subtitle", method: "disableSubtitle", - parameters: { pipelineId: showId }, + parameters: { pipelineId: mediaId }, onSuccess, onFailure, onComplete, @@ -176,19 +176,15 @@ export const setSubtitleEnable = ( // 5.0 export const setSubtitleEnableOver5 = ( - showId, + mediaId, captionEnable, { onSuccess, onFailure, onComplete } ) => { - if ( - typeof window === "object" && - window.PalmSystem && - process.env.REACT_APP_MODE !== "DEBUG" - ) { + if (typeof window === "object" && window.PalmSystem) { return new LS2Request().send({ service: "luna://com.webos.media", method: "setSubtitleEnable", - parameters: { enable: captionEnable, mediaId: showId }, + parameters: { enable: captionEnable, mediaId: mediaId }, onSuccess, onFailure, onComplete, diff --git a/com.twin.app.shoptime/src/views/PlayerPanel/PlayerPanel.jsx b/com.twin.app.shoptime/src/views/PlayerPanel/PlayerPanel.jsx index c95a7c5a..7b876202 100644 --- a/com.twin.app.shoptime/src/views/PlayerPanel/PlayerPanel.jsx +++ b/com.twin.app.shoptime/src/views/PlayerPanel/PlayerPanel.jsx @@ -132,6 +132,7 @@ const PlayerPanel = ({ const [playListInfo, setPlayListInfo] = useState(""); const [shopNowInfo, setShopNowInfo] = useState(); const [modalStyle, setModalStyle] = useState({}); + const [mediaId, setMediaId] = useState(null); const [sideContentsVisible, setSideContentsVisible] = useState(true); const [currentTime, setCurrentTime] = useState(0); @@ -680,10 +681,14 @@ const PlayerPanel = ({ }, [panelInfo, playListInfo]); useEffect(() => { - if (panelInfo?.shptmBanrTpNm === "LIVE" && playListInfo) { - dispatch(requestLiveSubtitle(playListInfo[selectedIndex].showId)); + if (mediaId && captionEnable && isSubtitleActive && panelInfo?.shptmBanrTpNm === "LIVE") { + dispatch(requestLiveSubtitle({mediaId, enable: true})); + }else { + if(mediaId){ + dispatch(requestLiveSubtitle({mediaId, enable: false})); + } } - }, [panelInfo?.shptmBanrTpNm, playListInfo, selectedIndex]); + }, [mediaId, captionEnable, isSubtitleActive]); useEffect(() => { if (!panelInfo) return; @@ -732,7 +737,7 @@ const PlayerPanel = ({ const mediainfoHandler = useCallback((ev) => { const type = ev.type; - if (type !== "timeupdate") { + if (type !== "timeupdate" && type !== 'durationchange') { console.log( "mediainfoHandler....", type, @@ -763,8 +768,9 @@ const PlayerPanel = ({ ); break; } - case "loadeddata": { - console.log("#loadeddata...."); + case 'loadeddata': { + const mediaId = videoPlayer.current?.video?.media?.mediaId; + setMediaId(mediaId); } } }, []); @@ -915,6 +921,14 @@ const PlayerPanel = ({ return false; }, [playListInfo, shopNowInfo, panelInfo.modal]); + + useEffect(() => { + if(mediaId){ + dispatch(requestLiveSubtitle({mediaId, enable: false})); + } + setMediaId(null); + }, [currentPlayingUrl]); + useEffect(() => { if (currentSubtTitleUrl) { dispatch(getSubTitle({ showSubtitleUrl: currentSubtTitleUrl }));