Java Code Examples for com.google.android.exoplayer2.ExoPlaybackException#getRendererException()

The following examples show how to use com.google.android.exoplayer2.ExoPlaybackException#getRendererException() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PlayerActivity.java    From leafpicrevived with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onPlayerError(ExoPlaybackException e) {
    String errorString = null;
    if (e.type == ExoPlaybackException.TYPE_RENDERER) {
        Exception cause = e.getRendererException();
        if (cause instanceof DecoderInitializationException) {
            // Special case for decoder initialization failures.
            DecoderInitializationException decoderInitializationException =
                    (DecoderInitializationException) cause;
            if (decoderInitializationException.decoderName == null)
                if (decoderInitializationException.getCause() instanceof DecoderQueryException)
                    errorString = getString(R.string.error_querying_decoders);
                else if (decoderInitializationException.secureDecoderRequired)
                    errorString = getString(R.string.error_no_secure_decoder, decoderInitializationException.mimeType);
                else
                    errorString = getString(R.string.error_no_decoder, decoderInitializationException.mimeType);
            else
                errorString = getString(R.string.error_instantiating_decoder, decoderInitializationException.decoderName);
        }
    }
    if (errorString != null)
        showToast(errorString);
    inErrorState = true;
    supportInvalidateOptionsMenu();
    showControls();
}
 
Example 2
Source File: Alarmio.java    From Alarmio with Apache License 2.0 6 votes vote down vote up
@Override
public void onPlayerError(ExoPlaybackException error) {
    String lastStream = currentStream;
    currentStream = null;
    Exception exception;
    switch (error.type) {
        case ExoPlaybackException.TYPE_RENDERER:
            exception = error.getRendererException();
            break;
        case ExoPlaybackException.TYPE_SOURCE:
            if (lastStream != null && error.getSourceException().getMessage().contains("does not start with the #EXTM3U header")) {
                playStream(lastStream, SoundData.TYPE_RADIO, progressiveMediaSourceFactory);
                return;
            }
            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();
}
 
Example 3
Source File: ReactExoplayerView.java    From react-native-video with MIT License 6 votes vote down vote up
@Override
public void onPlayerError(ExoPlaybackException e) {
    String errorString = "ExoPlaybackException type : " + e.type;
    Exception ex = e;
    if (e.type == ExoPlaybackException.TYPE_RENDERER) {
        Exception cause = e.getRendererException();
        if (cause instanceof MediaCodecRenderer.DecoderInitializationException) {
            // Special case for decoder initialization failures.
            MediaCodecRenderer.DecoderInitializationException decoderInitializationException =
                    (MediaCodecRenderer.DecoderInitializationException) cause;
            if (decoderInitializationException.codecInfo.name == null) {
                if (decoderInitializationException.getCause() instanceof MediaCodecUtil.DecoderQueryException) {
                    errorString = getResources().getString(R.string.error_querying_decoders);
                } else if (decoderInitializationException.secureDecoderRequired) {
                    errorString = getResources().getString(R.string.error_no_secure_decoder,
                            decoderInitializationException.mimeType);
                } else {
                    errorString = getResources().getString(R.string.error_no_decoder,
                            decoderInitializationException.mimeType);
                }
            } else {
                errorString = getResources().getString(R.string.error_instantiating_decoder,
                        decoderInitializationException.codecInfo.name);
            }
        }
    }
    else if (e.type == ExoPlaybackException.TYPE_SOURCE) {
        errorString = getResources().getString(R.string.unrecognized_media_format);
    }
    eventEmitter.error(errorString, ex);
    playerNeedsSource = true;
    if (isBehindLiveWindow(e)) {
        clearResumePosition();
        initializePlayer();
    } else {
        updateResumePosition();
    }
}
 
Example 4
Source File: MediaPlayerFragment.java    From PowerFileExplorer with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onPlayerError(ExoPlaybackException e) {
	String errorString = null;
	if (e.type == ExoPlaybackException.TYPE_RENDERER) {
		Exception cause = e.getRendererException();
		if (cause instanceof DecoderInitializationException) {
			// Special case for decoder initialization failures.
			DecoderInitializationException decoderInitializationException =
				(DecoderInitializationException) cause;
			if (decoderInitializationException.decoderName == null) {
				if (decoderInitializationException.getCause() instanceof DecoderQueryException) {
					errorString = getString(R.string.error_querying_decoders);
				} else if (decoderInitializationException.secureDecoderRequired) {
					errorString = getString(R.string.error_no_secure_decoder,
											decoderInitializationException.mimeType);
				} else {
					errorString = getString(R.string.error_no_decoder,
											decoderInitializationException.mimeType);
				}
			} else {
				errorString = getString(R.string.error_instantiating_decoder,
										decoderInitializationException.decoderName);
			}
		}
	}
	if (errorString != null) {
		showToast(errorString);
	}
	needRetrySource = true;
	if (isBehindLiveWindow(e)) {
		clearResumePosition();
		initializePlayer();
	} else {
		updateResumePosition();
		updateButtonVisibilities();
		showControls();
	}
}
 
Example 5
Source File: PlayerActivity.java    From ExoPlayer-Offline with Apache License 2.0 5 votes vote down vote up
@Override
public void onPlayerError(ExoPlaybackException e) {
    String errorString = null;
    if (e.type == ExoPlaybackException.TYPE_RENDERER) {
        Exception cause = e.getRendererException();
        if (cause instanceof DecoderInitializationException) {
            // Special case for decoder initialization failures.
            DecoderInitializationException decoderInitializationException =
                    (DecoderInitializationException) cause;
            if (decoderInitializationException.decoderName == null) {
                if (decoderInitializationException.getCause() instanceof DecoderQueryException) {
                    errorString = getString(R.string.error_querying_decoders);
                } else if (decoderInitializationException.secureDecoderRequired) {
                    errorString = getString(R.string.error_no_secure_decoder,
                            decoderInitializationException.mimeType);
                } else {
                    errorString = getString(R.string.error_no_decoder,
                            decoderInitializationException.mimeType);
                }
            } else {
                errorString = getString(R.string.error_instantiating_decoder,
                        decoderInitializationException.decoderName);
            }
        }
    }
    if (errorString != null) {
        showToast(errorString);
    }
    playerNeedsSource = true;
    if (isBehindLiveWindow(e)) {
        clearResumePosition();
        initializePlayer();
    } else {
        updateResumePosition();
        updateButtonVisibilities();
        showControls();
    }
}
 
Example 6
Source File: LiveVideoPlayerActivity.java    From LiveVideoBroadcaster with Apache License 2.0 5 votes vote down vote up
@Override
public void onPlayerError(ExoPlaybackException e) {
  videoStartControlLayout.setVisibility(View.VISIBLE);
  String errorString = null;
  if (e.type == ExoPlaybackException.TYPE_RENDERER) {
    Exception cause = e.getRendererException();
    if (cause instanceof DecoderInitializationException) {
      // Special case for decoder initialization failures.
      DecoderInitializationException decoderInitializationException =
              (DecoderInitializationException) cause;
      if (decoderInitializationException.decoderName == null) {
        if (decoderInitializationException.getCause() instanceof DecoderQueryException) {
          errorString = getString(R.string.error_querying_decoders);
        } else if (decoderInitializationException.secureDecoderRequired) {
          errorString = getString(R.string.error_no_secure_decoder,
                  decoderInitializationException.mimeType);
        } else {
          errorString = getString(R.string.error_no_decoder,
                  decoderInitializationException.mimeType);
        }
      } else {
        errorString = getString(R.string.error_instantiating_decoder,
                decoderInitializationException.decoderName);
      }
    }
  }
  if (errorString != null) {
    showToast(errorString);
  }
  needRetrySource = true;
  if (isBehindLiveWindow(e)) {
    clearResumePosition();
    play(null);
  } else {
    updateResumePosition();
    showControls();
  }
}
 
Example 7
Source File: VideoPlayerComponent.java    From android-arch-components-lifecycle with Apache License 2.0 5 votes vote down vote up
@Override
public void onPlayerError(ExoPlaybackException e) {
    String errorString = null;
    if (e.type == ExoPlaybackException.TYPE_RENDERER) {
        Exception cause = e.getRendererException();
        if (cause instanceof MediaCodecRenderer.DecoderInitializationException) {
            // Special case for decoder initialization failures.
            MediaCodecRenderer.DecoderInitializationException decoderInitializationException =
                    (MediaCodecRenderer.DecoderInitializationException) cause;
            if (decoderInitializationException.decoderName == null) {
                if (decoderInitializationException.getCause() instanceof MediaCodecUtil.DecoderQueryException) {
                    errorString = context.getString(R.string.error_querying_decoders);
                } else if (decoderInitializationException.secureDecoderRequired) {
                    errorString = context.getString(R.string.error_no_secure_decoder,
                            decoderInitializationException.mimeType);
                } else {
                    errorString = context.getString(R.string.error_no_decoder,
                            decoderInitializationException.mimeType);
                }
            } else {
                errorString = context.getString(R.string.error_instantiating_decoder,
                        decoderInitializationException.decoderName);
            }
        }
    }
    if (errorString != null) {
        showToast(errorString);
    }
    if (isBehindLiveWindow(e)) {
        clearResumePosition();
        initializePlayer();
    } else {
        updateResumePosition();

    }
}
 
Example 8
Source File: ExoPlayerHelper.java    From ExoPlayer-Wrapper with Apache License 2.0 4 votes vote down vote up
@Override
public void onPlayerError(ExoPlaybackException e) {
    String errorString = null;

    switch (e.type) {
        case ExoPlaybackException.TYPE_SOURCE:
            //https://github.com/google/ExoPlayer/issues/2702
            IOException ex = e.getSourceException();
            String msg = ex.getMessage();
            if (msg != null) {
                Log.e("ExoPlayerHelper", msg);
                errorString = msg;
            }
            break;
        case ExoPlaybackException.TYPE_RENDERER:
            Exception exception = e.getRendererException();
            if (exception.getMessage() != null) {
                Log.e("ExoPlayerHelper", exception.getMessage());
            }
            break;
        case ExoPlaybackException.TYPE_UNEXPECTED:
            RuntimeException runtimeException = e.getUnexpectedException();
            Log.e("ExoPlayerHelper", runtimeException.getMessage() == null ? "Message is null" : runtimeException.getMessage());
            if (runtimeException.getMessage() == null) {
                runtimeException.printStackTrace();
            }
            errorString = runtimeException.getMessage();
            break;
        case ExoPlaybackException.TYPE_OUT_OF_MEMORY:
            break;
        case ExoPlaybackException.TYPE_REMOTE:
            break;
    }


    if (e.type == ExoPlaybackException.TYPE_RENDERER) {
        Exception cause = e.getRendererException();
        if (cause instanceof MediaCodecRenderer.DecoderInitializationException) {
            // Special case for decoder initialization failures.
            MediaCodecRenderer.DecoderInitializationException decoderInitializationException =
                    (MediaCodecRenderer.DecoderInitializationException) cause;
            if (decoderInitializationException.decoderName == null) {
                if (decoderInitializationException.getCause() instanceof MediaCodecUtil.DecoderQueryException) {
                    errorString = mContext.getString(R.string.error_querying_decoders);
                } else if (decoderInitializationException.secureDecoderRequired) {
                    errorString = mContext.getString(R.string.error_no_secure_decoder,
                            decoderInitializationException.mimeType);
                } else {
                    errorString = mContext.getString(R.string.error_no_decoder,
                            decoderInitializationException.mimeType);
                }
            } else {
                errorString = mContext.getString(R.string.error_instantiating_decoder,
                        decoderInitializationException.decoderName);
            }
        }
    }
    if (errorString != null) {
        Log.e("ExoPlayerHelper", "errorString: " + errorString);
    }

    if (isBehindLiveWindow(e)) {
        createPlayer(true);
        Log.e("ExoPlayerHelper", "isBehindLiveWindow is true");
    }


    if (mExoPlayerListener != null) {
        mExoPlayerListener.onPlayerError(errorString);
    }
}
 
Example 9
Source File: VideoActivity.java    From evercam-android with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
    public void onPlayerError(ExoPlaybackException error) {
        String errorString = null;
        if (error.type == ExoPlaybackException.TYPE_RENDERER) {
            Exception cause = error.getRendererException();
            if (cause instanceof MediaCodecRenderer.DecoderInitializationException) {
                // Special case for decoder initialization failures.
                MediaCodecRenderer.DecoderInitializationException decoderInitializationException =
                        (MediaCodecRenderer.DecoderInitializationException) cause;
                if (decoderInitializationException.decoderName == null) {
                    if (decoderInitializationException.getCause() instanceof MediaCodecUtil.DecoderQueryException) {
                        errorString = getString(R.string.error_querying_decoders);
                    } else if (decoderInitializationException.secureDecoderRequired) {
                        errorString = getString(R.string.error_no_secure_decoder,
                                decoderInitializationException.mimeType);
                    } else {
                        errorString = getString(R.string.error_no_decoder,
                                decoderInitializationException.mimeType);
                    }
                } else {
                    errorString = getString(R.string.error_instantiating_decoder,
                            decoderInitializationException.decoderName);
                }
            }
        }
        if (errorString != null) {
            Log.e(TAG, errorString);
        }

        if (isBehindLiveWindow(error)) {
            clearResumePosition();
            preparePlayer();
        } else {
            Log.e("VIDEO FAILED","VIDEO FAILED LOADING NEW ONE.");
            updateResumePosition();
            onVideoLoadFailed();
        }



/*        Log.e(TAG, "onError");
        onVideoLoadFailed();
        playerNeedsPrepare = true;*/

    }