diff --git a/com.twin.app.shoptime/src/actions/commonActions.js b/com.twin.app.shoptime/src/actions/commonActions.js index 2f0b6bc6..f70bd99c 100644 --- a/com.twin.app.shoptime/src/actions/commonActions.js +++ b/com.twin.app.shoptime/src/actions/commonActions.js @@ -284,10 +284,41 @@ export const cancelFocusElement = () => () => { }; let broadcastTimer = null; -export const sendBroadCast = ({type, moreInfo}) => (dispatch, getState) => { - clearTimeout(broadcastTimer); - dispatch(changeBroadcastEvent({ type, moreInfo })); - broadcastTimer = setTimeout(() => { //clear after 500ms - dispatch(changeBroadcastEvent({})); - }, 500); -}; \ No newline at end of file +export const sendBroadCast = + ({ type, moreInfo }) => + (dispatch, getState) => { + clearTimeout(broadcastTimer); + dispatch(changeBroadcastEvent({ type, moreInfo })); + broadcastTimer = setTimeout(() => { + //clear after 500ms + dispatch(changeBroadcastEvent({})); + }, 500); + }; + +export const requestLiveSubtitle = + ({ showId }) => + (dispatch, getState) => { + const webOSVersion = getState().common.appStatus.webOSVersion; + const captionEnable = getState().common.appStatus.captionEnable; + + if (Number(webOSVersion) <= 4.5) { + lunaSend.setSubtitleEnable(showId, captionEnable, { + onSuccess: (res) => { + console.log(res); + }, + onFailure: (err) => { + console.log(err); + }, + }); + return; + } else { + lunaSend.setSubtitleEnableOver5(showId, { + onSuccess: (res) => { + console.log(res); + }, + onFailure: (err) => { + console.log(err); + }, + }); + } + }; diff --git a/com.twin.app.shoptime/src/lunaSend/common.js b/com.twin.app.shoptime/src/lunaSend/common.js index 3cecacb7..3adb332f 100644 --- a/com.twin.app.shoptime/src/lunaSend/common.js +++ b/com.twin.app.shoptime/src/lunaSend/common.js @@ -140,3 +140,60 @@ export function checkValidCountry(ricCode, country) { } } } + +// 3.0 ~ 4.5 +export const setSubtitleEnable = ( + showId, + captionEnable, + { onSuccess, onFailure, onComplete } +) => { + if ( + typeof window === "object" && + window.PalmSystem && + process.env.REACT_APP_MODE !== "DEBUG" + ) { + if (captionEnable) { + return new LS2Request().send({ + service: "luna://com.webos.service.tv.subtitle", + method: "enableSubtitle", + parameters: { pipelineId: showId }, + onSuccess, + onFailure, + onComplete, + }); + } else { + return new LS2Request().send({ + service: "luna://com.webos.service.tv.subtitle", + method: "disableSubtitle", + parameters: { pipelineId: showId }, + onSuccess, + onFailure, + onComplete, + }); + } + } +}; + +// 5.0 +export const setSubtitleEnableOver5 = ( + showId, + { onSuccess, onFailure, onComplete } +) => { + console.log("#sutitle action"); + if ( + typeof window === "object" && + window.PalmSystem && + process.env.REACT_APP_MODE !== "DEBUG" + ) { + console.log("###showId", showId); + console.log("#onSuccess", onSuccess); + return new LS2Request().send({ + service: "luna://com.webos.media", + method: "setSubtitleEnable", + parameters: { pipelineId: showId }, + 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 3ff8bb29..42ffc72b 100644 --- a/com.twin.app.shoptime/src/views/PlayerPanel/PlayerPanel.jsx +++ b/com.twin.app.shoptime/src/views/PlayerPanel/PlayerPanel.jsx @@ -16,6 +16,7 @@ import SpotlightContainerDecorator from "@enact/spotlight/SpotlightContainerDeco import dummyVtt from "../../../assets/mock/video.vtt"; import { changeLocalSettings, + requestLiveSubtitle, sendBroadCast, } from "../../actions/commonActions"; import { @@ -474,6 +475,12 @@ const PlayerPanel = ({ } }, [panelInfo, playListInfo]); + useEffect(() => { + if (panelInfo?.shptmBanrTpNm === "LIVE" && playListInfo) { + dispatch(requestLiveSubtitle(playListInfo[selectedIndex].showId)); + } + }, [panelInfo?.shptmBanrTpNm, playListInfo, selectedIndex]); + useEffect(() => { if (!panelInfo) return; switch (panelInfo.shptmBanrTpNm) {