player system subtitle

This commit is contained in:
yonghyon
2024-06-17 17:42:21 +09:00
parent d90b261a19
commit bcfd6481a6
3 changed files with 29 additions and 20 deletions

View File

@@ -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);
},

View File

@@ -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,

View File

@@ -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 }));