[PlayerPanel] liveSubtitle lunaAPI
This commit is contained in:
@@ -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);
|
||||
};
|
||||
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);
|
||||
},
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user