[PlayerPanel] liveSubtitle lunaAPI
This commit is contained in:
@@ -284,10 +284,41 @@ export const cancelFocusElement = () => () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let broadcastTimer = null;
|
let broadcastTimer = null;
|
||||||
export const sendBroadCast = ({type, moreInfo}) => (dispatch, getState) => {
|
export const sendBroadCast =
|
||||||
clearTimeout(broadcastTimer);
|
({ type, moreInfo }) =>
|
||||||
dispatch(changeBroadcastEvent({ type, moreInfo }));
|
(dispatch, getState) => {
|
||||||
broadcastTimer = setTimeout(() => { //clear after 500ms
|
clearTimeout(broadcastTimer);
|
||||||
dispatch(changeBroadcastEvent({}));
|
dispatch(changeBroadcastEvent({ type, moreInfo }));
|
||||||
}, 500);
|
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 dummyVtt from "../../../assets/mock/video.vtt";
|
||||||
import {
|
import {
|
||||||
changeLocalSettings,
|
changeLocalSettings,
|
||||||
|
requestLiveSubtitle,
|
||||||
sendBroadCast,
|
sendBroadCast,
|
||||||
} from "../../actions/commonActions";
|
} from "../../actions/commonActions";
|
||||||
import {
|
import {
|
||||||
@@ -474,6 +475,12 @@ const PlayerPanel = ({
|
|||||||
}
|
}
|
||||||
}, [panelInfo, playListInfo]);
|
}, [panelInfo, playListInfo]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (panelInfo?.shptmBanrTpNm === "LIVE" && playListInfo) {
|
||||||
|
dispatch(requestLiveSubtitle(playListInfo[selectedIndex].showId));
|
||||||
|
}
|
||||||
|
}, [panelInfo?.shptmBanrTpNm, playListInfo, selectedIndex]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!panelInfo) return;
|
if (!panelInfo) return;
|
||||||
switch (panelInfo.shptmBanrTpNm) {
|
switch (panelInfo.shptmBanrTpNm) {
|
||||||
|
|||||||
Reference in New Issue
Block a user