How to catch all errors for ExoPlayer?
Thanks to feedback from ExoPlayer support, this should cover all problems.
@Override public void onPlayerError(ExoPlaybackException error) { switch (error.type) { case ExoPlaybackException.TYPE_SOURCE: Log.e(TAG, "TYPE_SOURCE: " + error.getSourceException().getMessage()); break; case ExoPlaybackException.TYPE_RENDERER: Log.e(TAG, "TYPE_RENDERER: " + error.getRendererException().getMessage()); break; case ExoPlaybackException.TYPE_UNEXPECTED: Log.e(TAG, "TYPE_UNEXPECTED: " + error.getUnexpectedException().getMessage()); break; } }
You could catch exoplayer errors like this:
this.player = new SimpleExoPlayer.Builder(PlayActivity.this).build();player.addListener(new Player.EventListener() { @Override public void onPlayerError(ExoPlaybackException error) { ..... }});
For Kotlin users the syntax is a bit different (I struggled with the object declaration):
// initialize and setup exo playerplayer = SimpleExoPlayer.Builder(applicationContext).build()// setup error listenerplayer.addListener(object : Player.EventListener { override fun onPlayerError(error: ExoPlaybackException) { log.debug("ExoPlayer error, ${error.sourceException.message}") }})