Commit 2d97d3a5 by kimvde Committed by tonihei

Make sure errors thrown in the PlayerListener are not swallowed

PiperOrigin-RevId: 515037497
parent bfad60e6
...@@ -300,6 +300,7 @@ public final class ExoPlayerAssetLoader implements AssetLoader { ...@@ -300,6 +300,7 @@ public final class ExoPlayerAssetLoader implements AssetLoader {
@Override @Override
public void onTimelineChanged(Timeline timeline, int reason) { public void onTimelineChanged(Timeline timeline, int reason) {
try {
if (progressState != PROGRESS_STATE_WAITING_FOR_AVAILABILITY) { if (progressState != PROGRESS_STATE_WAITING_FOR_AVAILABILITY) {
return; return;
} }
...@@ -307,8 +308,8 @@ public final class ExoPlayerAssetLoader implements AssetLoader { ...@@ -307,8 +308,8 @@ public final class ExoPlayerAssetLoader implements AssetLoader {
timeline.getWindow(/* windowIndex= */ 0, window); timeline.getWindow(/* windowIndex= */ 0, window);
if (!window.isPlaceholder) { if (!window.isPlaceholder) {
long durationUs = window.durationUs; long durationUs = window.durationUs;
// Make progress permanently unavailable if the duration is unknown, so that it doesn't jump // Make progress permanently unavailable if the duration is unknown, so that it doesn't
// to a high value at the end of the export if the duration is set once the media is // jump to a high value at the end of the export if the duration is set once the media is
// entirely loaded. // entirely loaded.
progressState = progressState =
durationUs <= 0 || durationUs == C.TIME_UNSET durationUs <= 0 || durationUs == C.TIME_UNSET
...@@ -316,10 +317,15 @@ public final class ExoPlayerAssetLoader implements AssetLoader { ...@@ -316,10 +317,15 @@ public final class ExoPlayerAssetLoader implements AssetLoader {
: PROGRESS_STATE_AVAILABLE; : PROGRESS_STATE_AVAILABLE;
assetLoaderListener.onDurationUs(window.durationUs); assetLoaderListener.onDurationUs(window.durationUs);
} }
} catch (RuntimeException e) {
assetLoaderListener.onError(
ExportException.createForAssetLoader(e, ERROR_CODE_UNSPECIFIED));
}
} }
@Override @Override
public void onTracksChanged(Tracks tracks) { public void onTracksChanged(Tracks tracks) {
try {
int trackCount = 0; int trackCount = 0;
if (tracks.isTypeSelected(C.TRACK_TYPE_AUDIO)) { if (tracks.isTypeSelected(C.TRACK_TYPE_AUDIO)) {
trackCount++; trackCount++;
...@@ -339,6 +345,10 @@ public final class ExoPlayerAssetLoader implements AssetLoader { ...@@ -339,6 +345,10 @@ public final class ExoPlayerAssetLoader implements AssetLoader {
new IllegalStateException("The asset loader has no track to output."), new IllegalStateException("The asset loader has no track to output."),
ERROR_CODE_FAILED_RUNTIME_CHECK)); ERROR_CODE_FAILED_RUNTIME_CHECK));
} }
} catch (RuntimeException e) {
assetLoaderListener.onError(
ExportException.createForAssetLoader(e, ERROR_CODE_UNSPECIFIED));
}
} }
@Override @Override
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment