From 7cd164ea2c9e9bdca38f6d32b053f0272ed10211 Mon Sep 17 00:00:00 2001 From: olivier bouillet Date: Mon, 2 Jan 2023 21:52:08 +0100 Subject: [PATCH 1/3] chore(android): small refactor to avoid unnecessary allocations --- .../exoplayer/ReactExoplayerView.java | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/android/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java b/android/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java index 05f612cd..93c39187 100644 --- a/android/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java +++ b/android/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java @@ -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; } From 8c954647883a72cf8af5de8ac39186ec22a90e34 Mon Sep 17 00:00:00 2001 From: olivier bouillet Date: Mon, 2 Jan 2023 21:52:41 +0100 Subject: [PATCH 2/3] fix(android): fix tracks selection --- .../main/java/com/brentvatne/exoplayer/ReactExoplayerView.java | 1 + 1 file changed, 1 insertion(+) diff --git a/android/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java b/android/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java index 93c39187..c2cd274e 100644 --- a/android/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java +++ b/android/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java @@ -1687,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); From 485df83e3312dc1b8919ffb8d7bcbb58cc8a0397 Mon Sep 17 00:00:00 2001 From: olivier bouillet Date: Mon, 2 Jan 2023 21:57:12 +0100 Subject: [PATCH 3/3] chore: update changeLog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3a3c5257..6e3ecbca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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)