Skip to content

Commit 44b626a

Browse files
authored
Merge pull request TheWidlarzGroup#1233 from react-native-community/bugfix/no-audio-crash
Avoid crash when there are no tracks to choose from
2 parents b514246 + 5e36060 commit 44b626a

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -830,6 +830,10 @@ public void setSelectedTrack(int trackType, String type, Dynamic value) {
830830
}
831831

832832
private int getTrackIndexForDefaultLocale(TrackGroupArray groups) {
833+
if (groups.length == 0) { // Avoid a crash if we try to select a non-existant group
834+
return C.INDEX_UNSET;
835+
}
836+
833837
int trackIndex = 0; // default if no match
834838
String locale2 = Locale.getDefault().getLanguage(); // 2 letter code
835839
String locale3 = Locale.getDefault().getISO3Language(); // 3 letter code

0 commit comments

Comments
 (0)