Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/android text tracks #2979

Merged
merged 3 commits into from
Jan 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1531,6 +1531,14 @@ public void setPreventsDisplaySleepDuringVideoPlayback(boolean preventsDisplaySl
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);
Expand All @@ -1551,13 +1559,8 @@ public void setSelectedTrack(int trackType, String type, Dynamic value) {
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) {
Expand Down Expand Up @@ -1675,7 +1678,7 @@ public void setSelectedTrack(int trackType, String type, Dynamic value) {
}

if (groupIndex == C.INDEX_UNSET) {
trackSelector.setParameters(disableParameters);
disableTrack(rendererIndex);
return;
}

Expand All @@ -1684,6 +1687,7 @@ public void setSelectedTrack(int trackType, String type, Dynamic value) {
DefaultTrackSelector.Parameters selectionParameters = trackSelector.getParameters()
.buildUpon()
.setRendererDisabled(rendererIndex, false)
.clearOverridesOfType(selectionOverride.getType())
.addOverride(selectionOverride)
.build();
trackSelector.setParameters(selectionParameters);
Expand Down