fix(android): video tracks crash and clean (#3767)

* perf: ensure we do not provide callback to native if no callback provided from app

* chore: rework bufferConfig to make it more generic and reduce ReactExoplayerView code size

* chore: improve issue template

* fix(android): avoid video view flickering at playback startup

* fix: fix crash when invalid index type is provided and minor clean up
This commit is contained in:
Olivier Bouillet 2024-05-14 16:39:41 +02:00 committed by GitHub
parent 98b4a75a90
commit 219496ff3a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1358,7 +1358,7 @@ public class ReactExoplayerView extends FrameLayout implements
videoTrack.setHeight(format.height == Format.NO_VALUE ? 0 : format.height);
videoTrack.setBitrate(format.bitrate == Format.NO_VALUE ? 0 : format.bitrate);
if (format.codecs != null) videoTrack.setCodecs(format.codecs);
videoTrack.setTrackId(format.id == null ? String.valueOf(trackIndex) : format.id);;
videoTrack.setTrackId(format.id == null ? String.valueOf(trackIndex) : format.id);
return videoTrack;
}
@ -1798,10 +1798,15 @@ public class ReactExoplayerView extends FrameLayout implements
}
}
} else if ("index".equals(type)) {
try {
int iValue = Integer.parseInt(value);
if (iValue < groups.length) {
groupIndex = iValue;
}
} catch (Exception e) {
DebugLog.e(TAG, "cannot parse index:" + value);
groupIndex = 0;
}
} else if ("resolution".equals(type)) {
int height = Integer.parseInt(value);
for (int i = 0; i < groups.length; ++i) { // Search for the exact height
@ -1866,7 +1871,6 @@ public class ReactExoplayerView extends FrameLayout implements
if (groupIndex == C.INDEX_UNSET && trackType == C.TRACK_TYPE_VIDEO && groups.length != 0) { // Video auto
// Add all tracks as valid options for ABR to choose from
TrackGroup group = groups.get(0);
tracks = new ArrayList<>(group.length);
ArrayList<Integer> allTracks = new ArrayList<>(group.length);
groupIndex = 0;
for (int j = 0; j < group.length; j++) {