mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +00:00
Make sure errors thrown in the PlayerListener are not swallowed
PiperOrigin-RevId: 515037497
This commit is contained in:
parent
bfad60e661
commit
2d97d3a571
1 changed files with 41 additions and 31 deletions
|
|
@ -300,44 +300,54 @@ public final class ExoPlayerAssetLoader implements AssetLoader {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTimelineChanged(Timeline timeline, int reason) {
|
public void onTimelineChanged(Timeline timeline, int reason) {
|
||||||
if (progressState != PROGRESS_STATE_WAITING_FOR_AVAILABILITY) {
|
try {
|
||||||
return;
|
if (progressState != PROGRESS_STATE_WAITING_FOR_AVAILABILITY) {
|
||||||
}
|
return;
|
||||||
Timeline.Window window = new Timeline.Window();
|
}
|
||||||
timeline.getWindow(/* windowIndex= */ 0, window);
|
Timeline.Window window = new Timeline.Window();
|
||||||
if (!window.isPlaceholder) {
|
timeline.getWindow(/* windowIndex= */ 0, window);
|
||||||
long durationUs = window.durationUs;
|
if (!window.isPlaceholder) {
|
||||||
// Make progress permanently unavailable if the duration is unknown, so that it doesn't jump
|
long durationUs = window.durationUs;
|
||||||
// to a high value at the end of the export if the duration is set once the media is
|
// Make progress permanently unavailable if the duration is unknown, so that it doesn't
|
||||||
// entirely loaded.
|
// jump to a high value at the end of the export if the duration is set once the media is
|
||||||
progressState =
|
// entirely loaded.
|
||||||
durationUs <= 0 || durationUs == C.TIME_UNSET
|
progressState =
|
||||||
? PROGRESS_STATE_UNAVAILABLE
|
durationUs <= 0 || durationUs == C.TIME_UNSET
|
||||||
: PROGRESS_STATE_AVAILABLE;
|
? PROGRESS_STATE_UNAVAILABLE
|
||||||
assetLoaderListener.onDurationUs(window.durationUs);
|
: PROGRESS_STATE_AVAILABLE;
|
||||||
|
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) {
|
||||||
int trackCount = 0;
|
try {
|
||||||
if (tracks.isTypeSelected(C.TRACK_TYPE_AUDIO)) {
|
int trackCount = 0;
|
||||||
trackCount++;
|
if (tracks.isTypeSelected(C.TRACK_TYPE_AUDIO)) {
|
||||||
}
|
trackCount++;
|
||||||
if (tracks.isTypeSelected(C.TRACK_TYPE_VIDEO)) {
|
}
|
||||||
trackCount++;
|
if (tracks.isTypeSelected(C.TRACK_TYPE_VIDEO)) {
|
||||||
}
|
trackCount++;
|
||||||
|
}
|
||||||
|
|
||||||
if (trackCount > 0) {
|
if (trackCount > 0) {
|
||||||
assetLoaderListener.onTrackCount(trackCount);
|
assetLoaderListener.onTrackCount(trackCount);
|
||||||
// Start the renderers after having registered all the tracks to make sure the AssetLoader
|
// Start the renderers after having registered all the tracks to make sure the AssetLoader
|
||||||
// listener callbacks are called in the right order.
|
// listener callbacks are called in the right order.
|
||||||
player.play();
|
player.play();
|
||||||
} else {
|
} else {
|
||||||
|
assetLoaderListener.onError(
|
||||||
|
ExportException.createForAssetLoader(
|
||||||
|
new IllegalStateException("The asset loader has no track to output."),
|
||||||
|
ERROR_CODE_FAILED_RUNTIME_CHECK));
|
||||||
|
}
|
||||||
|
} catch (RuntimeException e) {
|
||||||
assetLoaderListener.onError(
|
assetLoaderListener.onError(
|
||||||
ExportException.createForAssetLoader(
|
ExportException.createForAssetLoader(e, ERROR_CODE_UNSPECIFIED));
|
||||||
new IllegalStateException("The asset loader has no track to output."),
|
|
||||||
ERROR_CODE_FAILED_RUNTIME_CHECK));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue