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

The following examples show how to use com.google.android.exoplayer2.ExoPlaybackException#getSourceException() . 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: MediaPlayerFragment.java    From PowerFileExplorer with GNU General Public License v3.0 6 votes vote down vote up
private static boolean isBehindLiveWindow(ExoPlaybackException e) {
	if (e.type != ExoPlaybackException.TYPE_SOURCE) {
		return false;
	}
	Throwable cause = e.getSourceException();
	while (cause != null) {
		if (cause instanceof BehindLiveWindowException) {
			return true;
		}
		cause = cause.getCause();
	}
	return false;
}
 
Example 2
Source File: PlayerActivity.java    From ExoPlayer-Offline with Apache License 2.0 6 votes vote down vote up
private static boolean isBehindLiveWindow(ExoPlaybackException e) {
    if (e.type != ExoPlaybackException.TYPE_SOURCE) {
        return false;
    }
    Throwable cause = e.getSourceException();
    while (cause != null) {
        if (cause instanceof BehindLiveWindowException) {
            return true;
        }
        cause = cause.getCause();
    }
    return false;
}
 
Example 3
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 4
Source File: ExoPlayerHelper.java    From ExoPlayer-Wrapper with Apache License 2.0 6 votes vote down vote up
private static boolean isBehindLiveWindow(ExoPlaybackException e) {
    if (e.type != ExoPlaybackException.TYPE_SOURCE) {
        return false;
    }
    Throwable cause = e.getSourceException();
    while (cause != null) {
        if (cause instanceof BehindLiveWindowException) {
            return true;
        }
        cause = cause.getCause();
    }
    return false;
}
 
Example 5
Source File: LiveVideoPlayerActivity.java    From LiveVideoBroadcaster with Apache License 2.0 6 votes vote down vote up
private static boolean isBehindLiveWindow(ExoPlaybackException e) {
  if (e.type != ExoPlaybackException.TYPE_SOURCE) {
    return false;
  }
  Throwable cause = e.getSourceException();
  while (cause != null) {
    if (cause instanceof BehindLiveWindowException) {
      return true;
    }
    cause = cause.getCause();
  }
  return false;
}
 
Example 6
Source File: VideoPlayerComponent.java    From android-arch-components-lifecycle with Apache License 2.0 6 votes vote down vote up
private static boolean isBehindLiveWindow(ExoPlaybackException e) {
    if (e.type != ExoPlaybackException.TYPE_SOURCE) {
        return false;
    }
    Throwable cause = e.getSourceException();
    while (cause != null) {
        if (cause instanceof BehindLiveWindowException) {
            return true;
        }
        cause = cause.getCause();
    }
    return false;
}
 
Example 7
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 8
Source File: VideoActivity.java    From evercam-android with GNU Affero General Public License v3.0 5 votes vote down vote up
private static boolean isBehindLiveWindow(ExoPlaybackException e) {
    if (e.type != ExoPlaybackException.TYPE_SOURCE) {
        return false;
    }
    Throwable cause = e.getSourceException();
    while (cause != null) {
        if (cause instanceof BehindLiveWindowException) {
            return true;
        }
        cause = cause.getCause();
    }
    return false;
}
 
Example 9
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);
    }
}