fix(android)!: rework video tracks management (#3778)
* fix: fix crash when invalid index type is provided and minor clean up * fix: review video track management. Fix index support and rework string vs int in tracks management * fix: ABR track selection check * fix: split track selector in sample and lint code * fix: ensure we don't report null fields * chore: improve tracks displayed * chore: start moving to selection by index only
This commit is contained in:
@@ -9,7 +9,7 @@ class VideoTrack {
|
||||
var height = 0
|
||||
var bitrate = 0
|
||||
var codecs = ""
|
||||
var id = -1
|
||||
var index = -1
|
||||
var trackId = ""
|
||||
var isSelected = false
|
||||
}
|
||||
|
@@ -194,9 +194,15 @@ public class VideoEventEmitter {
|
||||
WritableMap audioTrack = Arguments.createMap();
|
||||
audioTrack.putInt("index", i);
|
||||
audioTrack.putString("title", format.getTitle());
|
||||
audioTrack.putString("type", format.getMimeType());
|
||||
audioTrack.putString("language", format.getLanguage());
|
||||
audioTrack.putInt("bitrate", format.getBitrate());
|
||||
if (format.getMimeType() != null) {
|
||||
audioTrack.putString("type", format.getMimeType());
|
||||
}
|
||||
if (format.getLanguage() != null) {
|
||||
audioTrack.putString("language", format.getLanguage());
|
||||
}
|
||||
if (format.getBitrate() > 0) {
|
||||
audioTrack.putInt("bitrate", format.getBitrate());
|
||||
}
|
||||
audioTrack.putBoolean("selected", format.isSelected());
|
||||
waAudioTracks.pushMap(audioTrack);
|
||||
}
|
||||
@@ -214,7 +220,8 @@ public class VideoEventEmitter {
|
||||
videoTrack.putInt("height",vTrack.getHeight());
|
||||
videoTrack.putInt("bitrate", vTrack.getBitrate());
|
||||
videoTrack.putString("codecs", vTrack.getCodecs());
|
||||
videoTrack.putInt("trackId",vTrack.getId());
|
||||
videoTrack.putString("trackId", vTrack.getTrackId());
|
||||
videoTrack.putInt("index", vTrack.getIndex());
|
||||
videoTrack.putBoolean("selected", vTrack.isSelected());
|
||||
waVideoTracks.pushMap(videoTrack);
|
||||
}
|
||||
|
@@ -36,8 +36,8 @@ public final class ExoPlayerView extends FrameLayout implements AdViewProvider {
|
||||
private final AspectRatioFrameLayout layout;
|
||||
private final ComponentListener componentListener;
|
||||
private ExoPlayer player;
|
||||
private Context context;
|
||||
private ViewGroup.LayoutParams layoutParams;
|
||||
private final Context context;
|
||||
private final ViewGroup.LayoutParams layoutParams;
|
||||
private final FrameLayout adOverlayFrameLayout;
|
||||
|
||||
private boolean useTextureView = true;
|
||||
|
@@ -1428,13 +1428,14 @@ public class ReactExoplayerView extends FrameLayout implements
|
||||
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.setIndex(trackIndex);
|
||||
return videoTrack;
|
||||
}
|
||||
|
||||
private ArrayList<VideoTrack> getVideoTrackInfo() {
|
||||
ArrayList<VideoTrack> videoTracks = new ArrayList<>();
|
||||
if (trackSelector == null) {
|
||||
// Likely player is unmounting so no audio tracks are available anymore
|
||||
// Likely player is unmounting so no video tracks are available anymore
|
||||
return videoTracks;
|
||||
}
|
||||
MappingTrackSelector.MappedTrackInfo info = trackSelector.getCurrentMappedTrackInfo();
|
||||
@@ -1869,14 +1870,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);
|
||||
int iValue = Integer.parseInt(value);
|
||||
|
||||
if (trackType == C.TRACK_TYPE_VIDEO && groups.length == 1) {
|
||||
groupIndex = 0;
|
||||
if (iValue < groups.get(groupIndex).length) {
|
||||
tracks.set(0, iValue);
|
||||
}
|
||||
} else if (iValue < groups.length) {
|
||||
groupIndex = iValue;
|
||||
}
|
||||
} else if ("resolution".equals(type)) {
|
||||
int height = Integer.parseInt(value);
|
||||
|
Reference in New Issue
Block a user