chore(android): add null check for id of videoFormat (#4174)
* chore(android): add null check for id of videoFormat * chore: null check videoFormat.id on onBandwidthSample * fix: PR feedback * fix: linter error * chore: update trackId fallback value
This commit is contained in:
committed by
GitHub
parent
0538b3b468
commit
1ef2b3a977
@@ -139,7 +139,6 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
@@ -385,12 +384,13 @@ public class ReactExoplayerView extends FrameLayout implements
|
||||
public void onBandwidthSample(int elapsedMs, long bytes, long bitrate) {
|
||||
if (mReportBandwidth) {
|
||||
if (player == null) {
|
||||
eventEmitter.onVideoBandwidthUpdate.invoke(bitrate, 0, 0, "-1");
|
||||
eventEmitter.onVideoBandwidthUpdate.invoke(bitrate, 0, 0, null);
|
||||
} else {
|
||||
Format videoFormat = player.getVideoFormat();
|
||||
int width = videoFormat != null ? videoFormat.width : 0;
|
||||
int height = videoFormat != null ? videoFormat.height : 0;
|
||||
String trackId = videoFormat != null ? videoFormat.id : "-1";
|
||||
boolean isRotatedContent = videoFormat != null && (videoFormat.rotationDegrees == 90 || videoFormat.rotationDegrees == 270);
|
||||
int width = videoFormat != null ? (isRotatedContent ? videoFormat.height : videoFormat.width) : 0;
|
||||
int height = videoFormat != null ? (isRotatedContent ? videoFormat.width : videoFormat.height) : 0;
|
||||
String trackId = videoFormat != null ? videoFormat.id : null;
|
||||
eventEmitter.onVideoBandwidthUpdate.invoke(bitrate, height, width, trackId);
|
||||
}
|
||||
}
|
||||
@@ -1427,7 +1427,7 @@ public class ReactExoplayerView extends FrameLayout implements
|
||||
boolean isRotatedContent = videoFormat != null && (videoFormat.rotationDegrees == 90 || videoFormat.rotationDegrees == 270);
|
||||
int width = videoFormat != null ? (isRotatedContent ? videoFormat.height : videoFormat.width) : 0;
|
||||
int height = videoFormat != null ? (isRotatedContent ? videoFormat.width : videoFormat.height) : 0;
|
||||
String trackId = videoFormat != null ? videoFormat.id : "-1";
|
||||
String trackId = videoFormat != null ? videoFormat.id : null;
|
||||
|
||||
// Properties that must be accessed on the main thread
|
||||
long duration = player.getDuration();
|
||||
|
Reference in New Issue
Block a user