Return unset track index when there are no track available (#1190)

This commit is contained in:
Hampton Maxwell 2018-09-12 19:38:11 -07:00
parent b5142460ac
commit 5e360608af

View File

@ -830,6 +830,10 @@ class ReactExoplayerView extends FrameLayout implements
} }
private int getTrackIndexForDefaultLocale(TrackGroupArray groups) { 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 int trackIndex = 0; // default if no match
String locale2 = Locale.getDefault().getLanguage(); // 2 letter code String locale2 = Locale.getDefault().getLanguage(); // 2 letter code
String locale3 = Locale.getDefault().getISO3Language(); // 3 letter code String locale3 = Locale.getDefault().getISO3Language(); // 3 letter code