From 5e360608af485bdec2ddaf61b782e4c5a76d63c5 Mon Sep 17 00:00:00 2001 From: Hampton Maxwell Date: Wed, 12 Sep 2018 19:38:11 -0700 Subject: [PATCH] Return unset track index when there are no track available (#1190) --- .../java/com/brentvatne/exoplayer/ReactExoplayerView.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java b/android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java index e098c72a..0c1a178f 100644 --- a/android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java +++ b/android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java @@ -830,6 +830,10 @@ class ReactExoplayerView extends FrameLayout implements } private int getTrackIndexForDefaultLocale(TrackGroupArray groups) { + if (groups.length == 0) { // Avoid a crash if we try to select a non-existant group + return C.INDEX_UNSET; + } + int trackIndex = 0; // default if no match String locale2 = Locale.getDefault().getLanguage(); // 2 letter code String locale3 = Locale.getDefault().getISO3Language(); // 3 letter code