} catch (ExoPlaybackException e) { assertThat(e.getUnexpectedException()).isInstanceOf(IllegalSeekPositionException.class);
} catch (ExoPlaybackException e) { assertThat(e.getUnexpectedException()).isInstanceOf(IllegalSeekPositionException.class);
@Test public void testPlaybackErrorDuringSourceInfoRefreshStillUpdatesTimeline() throws Exception { final Timeline timeline = new FakeTimeline(/* windowCount= */ 1); final FakeMediaSource mediaSource = new FakeMediaSource(/* timeline= */ null, /* manifest= */ null); ActionSchedule actionSchedule = new ActionSchedule.Builder("testPlaybackErrorDuringSourceInfoRefreshStillUpdatesTimeline") .waitForPlaybackState(Player.STATE_BUFFERING) // Cause an internal exception by seeking to an invalid position while the media source // is still being prepared. The error will be thrown while the player handles the new // source info. .seek(/* windowIndex= */ 100, /* positionMs= */ 0) .executeRunnable(() -> mediaSource.setNewSourceInfo(timeline, /* newManifest= */ null)) .waitForPlaybackState(Player.STATE_IDLE) .build(); ExoPlayerTestRunner testRunner = new ExoPlayerTestRunner.Builder() .setMediaSource(mediaSource) .setActionSchedule(actionSchedule) .build(context); try { testRunner.start().blockUntilActionScheduleFinished(TIMEOUT_MS).blockUntilEnded(TIMEOUT_MS); fail(); } catch (ExoPlaybackException e) { // Expected exception. assertThat(e.getUnexpectedException()).isInstanceOf(IllegalSeekPositionException.class); } testRunner.assertTimelinesEqual(timeline); testRunner.assertTimelineChangeReasonsEqual(Player.TIMELINE_CHANGE_REASON_PREPARED); }
@Override public void onPlayerError(ExoPlaybackException error) { currentStream = null; Exception exception; switch (error.type) { case ExoPlaybackException.TYPE_RENDERER: exception = error.getRendererException(); break; case ExoPlaybackException.TYPE_SOURCE: exception = error.getSourceException(); break; case ExoPlaybackException.TYPE_UNEXPECTED: exception = error.getUnexpectedException(); break; default: return; } exception.printStackTrace(); Toast.makeText(this, exception.getClass().getName() + ": " + exception.getMessage(), Toast.LENGTH_SHORT).show(); }
@Override public void onPlayerError(ExoPlaybackException error) { final String what; switch (error.type) { case ExoPlaybackException.TYPE_SOURCE: what = error.getSourceException().getMessage(); break; case ExoPlaybackException.TYPE_RENDERER: what = error.getRendererException().getMessage(); break; case ExoPlaybackException.TYPE_UNEXPECTED: what = error.getUnexpectedException().getMessage(); break; default: what = "Unknown: " + error; } if (mCallback != null) { mCallback.onError("ExoPlayer error " + what); } }
@Override public void onPlayerError(ExoPlaybackException error) { switch (error.type) { case TYPE_RENDERER: // error occurred in a Renderer LogHelper.e(LOG_TAG, "An error occurred. Type RENDERER: " + error.getRendererException().toString()); break; case TYPE_SOURCE: // error occurred loading data from a MediaSource. LogHelper.e(LOG_TAG, "An error occurred. Type SOURCE: " + error.getSourceException().toString()); break; case TYPE_UNEXPECTED: // error was an unexpected RuntimeException. LogHelper.e(LOG_TAG, "An error occurred. Type UNEXPECTED: " + error.getUnexpectedException().toString()); break; default: LogHelper.w(LOG_TAG, "An error occurred. Type OTHER ERROR."); break; } }
public static NoPlayer.PlayerError errorFor(ExoPlaybackException exception) { String message = ErrorFormatter.formatMessage(exception.getCause()); switch (exception.type) { case ExoPlaybackException.TYPE_SOURCE: return SourceErrorMapper.map(exception.getSourceException(), message); case ExoPlaybackException.TYPE_RENDERER: return RendererErrorMapper.map(exception.getRendererException(), message); case ExoPlaybackException.TYPE_UNEXPECTED: return UnexpectedErrorMapper.map(exception.getUnexpectedException(), message); default: return new NoPlayerError(PlayerErrorType.UNKNOWN, DetailErrorType.UNKNOWN, message); } } }