Skip to content

Commit

Permalink
Fix/doris 2687 player translation (#394)
Browse files Browse the repository at this point in the history
* bump doris-android to 3.11.18

* bump doris-android to 3.11.18, optimize player translation code, delete useless file
  • Loading branch information
WeiLiuSH authored Dec 17, 2024
1 parent 5a558ec commit 481d3c3
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 323 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
import com.brentvatne.entity.RNImaDaiSource;
import com.brentvatne.entity.RNMetadata;
import com.brentvatne.entity.RNSource;
import com.brentvatne.entity.RNTranslations;
import com.brentvatne.entity.RelatedVideo;
import com.brentvatne.entity.Watermark;
import com.brentvatne.react.R;
Expand Down Expand Up @@ -89,8 +88,7 @@
import com.diceplatform.doris.ui.ExoDorisPlayerView;
import com.diceplatform.doris.ui.ExoDorisPlayerViewListener;
import com.diceplatform.doris.ui.ExoDorisTvPlayerView;
import com.diceplatform.doris.ui.entity.Labels;
import com.diceplatform.doris.ui.entity.LabelsBuilder;
import com.diceplatform.doris.ui.entity.LabelsTranslation;
import com.diceplatform.doris.ui.entity.VideoTile;
import com.diceplatform.doris.ui.skipmarker.SkipMarker;
import com.diceplatform.doris.util.DorisExceptionUtil;
Expand Down Expand Up @@ -162,6 +160,12 @@ class ReactTVExoplayerView extends FrameLayout implements LifecycleEventListener
private static final String KEY_START_DATE = "startDate";
private static final String KEY_END_DATE = "endDate";

private static final String KEY_LABELS_LEARN_MORE = "learnMore";
private static final String KEY_LABELS_COUNT_DOWN_AD = "adsCountdownAd";
private static final String KEY_LABELS_COUNT_DOWN_OF = "adsCountdownOf";
private static final String KEY_LABELS_SKIP_IN = "skipAdIn";
private static final String KEY_LABELS_SKIP = "skipAd";

private static final int MAX_LOAD_BUFFER_MS = 30_000;

static {
Expand Down Expand Up @@ -199,7 +203,6 @@ class ReactTVExoplayerView extends FrameLayout implements LifecycleEventListener
// Props from React
private RNSource src;
private RNMetadata metadata;
private RNTranslations translations;
private boolean repeat;
private boolean disableFocus;
private boolean isLive = false;
Expand Down Expand Up @@ -524,12 +527,13 @@ private void doInitializePlayer(boolean force) {
AdViewProvider adViewProvider = adType == AdType.IMA_CSAI_LIVE
? secondaryPlayerView
: exoDorisPlayerView;
LabelsTranslation translations = exoDorisPlayerView.getLabelsTranslation();
AdLabels adLabels = translations == null ? null : new AdLabels(
translations.getLearnMoreLabel(),
translations.getAdsCountdownAdLabel(),
translations.getAdsCountdownOfLabel(),
translations.getSkipCountdownLabel(),
translations.getSkipLabel()
translations.get(KEY_LABELS_LEARN_MORE),
translations.get(KEY_LABELS_COUNT_DOWN_AD),
translations.get(KEY_LABELS_COUNT_DOWN_OF),
translations.get(KEY_LABELS_SKIP_IN),
translations.get(KEY_LABELS_SKIP)
);
AdGlobalSettings adGlobalSettings = new AdGlobalSettings(hideAdUiElements, isWhyThisAdIconEnabled, adLabels);

Expand Down Expand Up @@ -1852,9 +1856,10 @@ public void setOverlayAutoHideTimeout(Long hideTimeout) {
controlsAutoHideTimeout = hideTimeout;
}

public void applyTranslations(Map<String, Object> translations) {
this.translations = new RNTranslations(translations);
setLabelsOnPLayerUi();
public void setTranslations(Map<String, String> map) {
if (exoDorisPlayerView != null) {
exoDorisPlayerView.setTranslation(map);
}
}

public void applyPrimaryColor(@ColorInt int primaryColor) {
Expand All @@ -1863,35 +1868,6 @@ public void applyPrimaryColor(@ColorInt int primaryColor) {
}
}

private void setLabelsOnPLayerUi() {
if (exoDorisPlayerView != null && translations != null) {
Labels labels = new LabelsBuilder()
.setEpgLabel(translations.getEpgLabel())
.setStatsLabel(translations.getStatsLabel())
.setPlayLabel(translations.getPlayLabel())
.setPauseLabel(translations.getPauseLabel())
.setLiveLabel(translations.getLiveLabel())
.setFavoriteLabel(translations.getFavoriteLabel())
.setWatchlistLabel(translations.getWatchlistLabel())
.setMoreVideosLabel(translations.getMoreVideosLabel())
.setSubtitlesLabel(translations.getCaptionsLabel())
.setRewindLabel(translations.getRewindLabel())
.setFastForwardLabel(translations.getFastForwardLabel())
.setAudioLanguagesLabel(translations.getAudioTracksLabel())
.setInfoLabel(translations.getInfoLabel())
.setAnnotationsLabel(translations.getAnnotationsLabel())
.setAdsCountdownAdLabel(translations.getAdsCountdownAdLabel())
.setAdsCountdownOfLabel(translations.getAdsCountdownOfLabel())
.setPlayingLiveLabel(translations.getPlayingLiveLabel())
.setNowPlayingLabel(translations.getNowPlayingLabel())
.setAudioAndSubtitlesLabel(translations.getAudioAndSubtitlesLabel())
.setSkipCreditsLabel(translations.getSkipCreditsLabel())
.setSkipIntroLabel(translations.getSkipIntroLabel())
.build();
exoDorisPlayerView.setLabels(labels);
}
}

public void setSkipMarkers(List<SkipMarker> skipMarkers) {
exoDorisPlayerView.setSkipMarkList(skipMarkers);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
import com.facebook.react.uimanager.ViewGroupManager;
import com.facebook.react.uimanager.annotations.ReactProp;
import com.google.gson.Gson;
import com.imggaming.translations.DiceLocalizedStrings;

import java.util.ArrayList;
import java.util.HashMap;
Expand Down Expand Up @@ -577,8 +576,7 @@ public void setStateProgressBar(final ReactTVExoplayerView videoView, final Stri

@ReactProp(name = PROP_TRANSLATIONS)
public void setTranslations(final ReactTVExoplayerView videoView, @Nullable ReadableMap translations) {
DiceLocalizedStrings.getInstance().updateTranslations(toStringMap(translations));
videoView.applyTranslations(translations != null ? translations.toHashMap() : null);
videoView.setTranslations(toStringMap(translations));
}

@ReactProp(name = PROP_RELATED_VIDEOS)
Expand Down
Loading

0 comments on commit 481d3c3

Please sign in to comment.