Java Code Examples for com.google.android.exoplayer2.upstream.HttpDataSource#HttpDataSourceException

The following examples show how to use com.google.android.exoplayer2.upstream.HttpDataSource#HttpDataSourceException . 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: ReactExoplayerView.java    From react-native-video with MIT License 6 votes vote down vote up
private static boolean isBehindLiveWindow(ExoPlaybackException e) {
    Log.e("ExoPlayer Exception", e.toString());
    if (e.type != ExoPlaybackException.TYPE_SOURCE) {
        return false;
    }
    Throwable cause = e.getSourceException();
    while (cause != null) {
        if (cause instanceof BehindLiveWindowException ||
                cause instanceof HttpDataSource.HttpDataSourceException) {
            return true;
        }
        cause = cause.getCause();
    }
    return false;
}
 
Example 2
Source File: ProviderTvInputService.java    From xipl with Apache License 2.0 5 votes vote down vote up
@Override
public void onPlayerError(ExoPlaybackException error) {
    if (error.getCause() instanceof BehindLiveWindowException) {
        Toast.makeText(mContext, R.string.stream_failure_retry, Toast.LENGTH_SHORT).show();
        mProviderTvPlayer.restart(mContext);
        mProviderTvPlayer.play();
    } else if (error.getCause() instanceof UnrecognizedInputFormatException) {
        // Channel cannot be played in case of an error in parsing the ".m3u8" file.
        Toast.makeText(mContext, mContext.getString(R.string.channel_stream_failure), Toast.LENGTH_SHORT).show();
    } else if (error.getCause() instanceof HttpDataSource.InvalidResponseCodeException) {

         /*
          We might get errors different like 403 which indicate permission denied due to multiple
          connections at the same time or 502 meaning bad gateway.

          Restart the loading after 5 seconds.
          */

        Handler handler = new Handler();
        handler.postDelayed(new Runnable() {
            @Override
            public void run() {
                if (mContext != null && mProviderTvPlayer != null) {
                    Toast.makeText(mContext, R.string.stream_failure_retry, Toast.LENGTH_SHORT).show();
                    mProviderTvPlayer.restart(mContext);
                    mProviderTvPlayer.play();
                }
            }
        }, 5000);
    } else if (error.getCause() instanceof HttpDataSource.HttpDataSourceException) {
        // Timeout, nothing we can do really...
        Toast.makeText(mContext, R.string.channel_stream_failure, Toast.LENGTH_SHORT).show();
    }
}
 
Example 3
Source File: SourceErrorMapper.java    From no-player with Apache License 2.0 5 votes vote down vote up
private static NoPlayer.PlayerError mapHttpDataSourceException(HttpDataSource.HttpDataSourceException httpDataSourceException, String message) {
    switch (httpDataSourceException.type) {
        case HttpDataSource.HttpDataSourceException.TYPE_OPEN:
            return new NoPlayerError(PlayerErrorType.CONNECTIVITY, DetailErrorType.HTTP_CANNOT_OPEN_ERROR, message);
        case HttpDataSource.HttpDataSourceException.TYPE_READ:
            return new NoPlayerError(PlayerErrorType.CONNECTIVITY, DetailErrorType.HTTP_CANNOT_READ_ERROR, message);
        case HttpDataSource.HttpDataSourceException.TYPE_CLOSE:
            return new NoPlayerError(PlayerErrorType.CONNECTIVITY, DetailErrorType.HTTP_CANNOT_CLOSE_ERROR, message);
        default:
            return new NoPlayerError(PlayerErrorType.CONNECTIVITY, DetailErrorType.UNKNOWN, message);
    }
}
 
Example 4
Source File: PlayerEventHandler.java    From zapp with MIT License 5 votes vote down vote up
@Override
public void onLoadError(EventTime eventTime, MediaSourceEventListener.LoadEventInfo loadEventInfo, MediaSourceEventListener.MediaLoadData mediaLoadData, IOException error, boolean wasCanceled) {
	if (wasCanceled) {
		return;
	}

	Timber.e(error, "exo player onLoadError");

	if (error instanceof HttpDataSource.HttpDataSourceException) {
		errorResourceIdSource.onNext(R.string.error_stream_io);
	} else {
		errorResourceIdSource.onNext(R.string.error_stream_unknown);
	}
}