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