Merge pull request #2979 from iFeelSmart/fix/android-text-tracks

Android: fix text tracks selection
This commit is contained in:
Olivier Bouillet 2023-01-02 23:35:08 +01:00 committed by GitHub
commit 1596aeef0e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 7 deletions

View File

@ -4,6 +4,7 @@
- iOS: app crashes on call to presentFullScreenPlayer [#2808](https://github.com/react-native-video/react-native-video/pull/2971)
- Android: Fix publicated progress handler causing duplicated progress event [#2972](https://github.com/react-native-video/react-native-video/pull/2972)
- Android: Fix audio/Subtitle tracks selection [#2979](https://github.com/react-native-video/react-native-video/pull/2979)
- Feature: Add VAST support for AVOD [#2923](https://github.com/react-native-video/react-native-video/pull/2923)
- Sample: Upgrade react-native version of basic sample [#2960](https://github.com/react-native-video/react-native-video/pull/2960)

View File

@ -1531,6 +1531,14 @@ class ReactExoplayerView extends FrameLayout implements
this.preventsDisplaySleepDuringVideoPlayback = preventsDisplaySleepDuringVideoPlayback;
}
public void disableTrack(int rendererIndex) {
DefaultTrackSelector.Parameters disableParameters = trackSelector.getParameters()
.buildUpon()
.setRendererDisabled(rendererIndex, true)
.build();
trackSelector.setParameters(disableParameters);
}
public void setSelectedTrack(int trackType, String type, Dynamic value) {
if (player == null) return;
int rendererIndex = getTrackRendererIndex(trackType);
@ -1551,13 +1559,8 @@ class ReactExoplayerView extends FrameLayout implements
type = "default";
}
DefaultTrackSelector.Parameters disableParameters = trackSelector.getParameters()
.buildUpon()
.setRendererDisabled(rendererIndex, true)
.build();
if (type.equals("disabled")) {
trackSelector.setParameters(disableParameters);
disableTrack(rendererIndex);
return;
} else if (type.equals("language")) {
for (int i = 0; i < groups.length; ++i) {
@ -1675,7 +1678,7 @@ class ReactExoplayerView extends FrameLayout implements
}
if (groupIndex == C.INDEX_UNSET) {
trackSelector.setParameters(disableParameters);
disableTrack(rendererIndex);
return;
}
@ -1684,6 +1687,7 @@ class ReactExoplayerView extends FrameLayout implements
DefaultTrackSelector.Parameters selectionParameters = trackSelector.getParameters()
.buildUpon()
.setRendererDisabled(rendererIndex, false)
.clearOverridesOfType(selectionOverride.getType())
.addOverride(selectionOverride)
.build();
trackSelector.setParameters(selectionParameters);