Remove timeline reference from videoTrackInfo

This commit is contained in:
Armands Malejevs 2022-05-31 10:08:14 +03:00
parent 33b7bf1ee1
commit 9b04cfac51

View File

@ -1024,7 +1024,6 @@ class ReactExoplayerView extends FrameLayout implements
long currentPosition = player.getCurrentPosition(); long currentPosition = player.getCurrentPosition();
WritableArray audioTrackInfo = getAudioTrackInfo(); WritableArray audioTrackInfo = getAudioTrackInfo();
WritableArray textTrackInfo = getTextTrackInfo(); WritableArray textTrackInfo = getTextTrackInfo();
Timeline timelineRef = player.getCurrentTimeline();
int trackRendererIndex = getTrackRendererIndex(C.TRACK_TYPE_VIDEO); int trackRendererIndex = getTrackRendererIndex(C.TRACK_TYPE_VIDEO);
ExecutorService es = Executors.newSingleThreadExecutor(); ExecutorService es = Executors.newSingleThreadExecutor();
@ -1033,7 +1032,7 @@ class ReactExoplayerView extends FrameLayout implements
public void run() { public void run() {
// To prevent ANRs caused by getVideoTrackInfo we run this on a different thread and notify the player only when we're done // To prevent ANRs caused by getVideoTrackInfo we run this on a different thread and notify the player only when we're done
eventEmitter.load(duration, currentPosition, width, height, eventEmitter.load(duration, currentPosition, width, height,
audioTrackInfo, textTrackInfo, getVideoTrackInfo(timelineRef, trackRendererIndex), trackId); audioTrackInfo, textTrackInfo, getVideoTrackInfo(trackRendererIndex), trackId);
} }
}); });
} }
@ -1067,9 +1066,9 @@ class ReactExoplayerView extends FrameLayout implements
} }
return audioTracks; return audioTracks;
} }
private WritableArray getVideoTrackInfo(Timeline timelineRef, int trackRendererIndex) { private WritableArray getVideoTrackInfo(int trackRendererIndex) {
WritableArray contentVideoTracks = this.getVideoTrackInfoFromManifest(timelineRef); WritableArray contentVideoTracks = this.getVideoTrackInfoFromManifest();
if (contentVideoTracks != null) { if (contentVideoTracks != null) {
isUsingContentResolution = true; isUsingContentResolution = true;
return contentVideoTracks; return contentVideoTracks;
@ -1104,11 +1103,11 @@ class ReactExoplayerView extends FrameLayout implements
return videoTracks; return videoTracks;
} }
private WritableArray getVideoTrackInfoFromManifest(Timeline timeline) { private WritableArray getVideoTrackInfoFromManifest() {
return this.getVideoTrackInfoFromManifest(timeline, 0); return this.getVideoTrackInfoFromManifest(0);
} }
private WritableArray getVideoTrackInfoFromManifest(Timeline timelineRef, int retryCount) { private WritableArray getVideoTrackInfoFromManifest(int retryCount) {
ExecutorService es = Executors.newSingleThreadExecutor(); ExecutorService es = Executors.newSingleThreadExecutor();
final DataSource dataSource = this.mediaDataSourceFactory.createDataSource(); final DataSource dataSource = this.mediaDataSourceFactory.createDataSource();
final Uri sourceUri = this.srcUri; final Uri sourceUri = this.srcUri;
@ -1117,7 +1116,6 @@ class ReactExoplayerView extends FrameLayout implements
Future<WritableArray> result = es.submit(new Callable<WritableArray>() { Future<WritableArray> result = es.submit(new Callable<WritableArray>() {
DataSource ds = dataSource; DataSource ds = dataSource;
Uri uri = sourceUri; Uri uri = sourceUri;
Timeline timeline = timelineRef;
long startTimeUs = startTime * 1000; // ms -> us long startTimeUs = startTime * 1000; // ms -> us
public WritableArray call() throws Exception { public WritableArray call() throws Exception {
@ -1164,7 +1162,7 @@ class ReactExoplayerView extends FrameLayout implements
try { try {
WritableArray results = result.get(3000, TimeUnit.MILLISECONDS); WritableArray results = result.get(3000, TimeUnit.MILLISECONDS);
if (results == null && retryCount < 1) { if (results == null && retryCount < 1) {
return this.getVideoTrackInfoFromManifest(timelineRef, ++retryCount); return this.getVideoTrackInfoFromManifest(++retryCount);
} }
es.shutdown(); es.shutdown();
return results; return results;