Java Code Examples for com.google.android.exoplayer2.ExoPlaybackException#TYPE_UNEXPECTED

The following examples show how to use com.google.android.exoplayer2.ExoPlaybackException#TYPE_UNEXPECTED . 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: LocalPlayback.java    From YouTube-In-Background with MIT License 9 votes vote down vote up
@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;
    }

    LogHelper.e(TAG, "ExoPlayer error: what=" + what);
    if (callback != null) {
        callback.onError("ExoPlayer error " + what);
    }
}
 
Example 2
Source File: VideoPlayer.java    From edx-app-android with Apache License 2.0 8 votes vote down vote up
@Override
public void onPlayerError(ExoPlaybackException error) {
    if (lastCurrentPosition != 0) {
        seekToWhenPrepared = lastCurrentPosition;
    }
    state = PlayerState.ERROR;
    if (callback != null) {
        callback.onError();
    }

    if (error.type == ExoPlaybackException.TYPE_UNEXPECTED) {
        logger.warn("ERROR: unexpected");
    } else if (error.type == ExoPlaybackException.TYPE_RENDERER) {
        logger.warn("ERROR: renderer");
    } else if (error.type == ExoPlaybackException.TYPE_SOURCE) {
        logger.warn("ERROR: occurred while loading data from MediaSource");
    }
    logger.warn("ERROR: type=" + error.type + ";message=" + error.getMessage());
}
 
Example 3
Source File: RmxAudioPlayer.java    From flutter_plugin_playlist with MIT License 6 votes vote down vote up
@Override
public boolean onError(Exception e) {
    String errorMsg = e.toString();
    RmxAudioErrorType errorType = RmxAudioErrorType.RMXERR_NONE_SUPPORTED;

    if (e instanceof  ExoPlaybackException) {
        switch (((ExoPlaybackException) e).type) {
            case ExoPlaybackException.TYPE_SOURCE:
                errorMsg = "ExoPlaybackException.TYPE_SOURCE: " + ((ExoPlaybackException) e).getSourceException().getMessage();
                break;
            case ExoPlaybackException.TYPE_RENDERER:
                errorType = RmxAudioErrorType.RMXERR_DECODE;
                errorMsg = "ExoPlaybackException.TYPE_RENDERER: " + ((ExoPlaybackException) e).getRendererException().getMessage();
                break;
            case ExoPlaybackException.TYPE_UNEXPECTED:
                errorType = RmxAudioErrorType.RMXERR_DECODE;
                errorMsg = "ExoPlaybackException.TYPE_UNEXPECTED: " + ((ExoPlaybackException) e).getUnexpectedException().getMessage();
                break;
        }
    }

    AudioTrack errorItem = getPlaylistManager().getCurrentErrorTrack();
    String trackId = errorItem != null ? errorItem.getTrackId() : "INVALID";

    Log.i(TAG, "Error playing audio track: [" + trackId + "]: " + errorMsg);
    onError(errorType, trackId, errorMsg);
    getPlaylistManager().setCurrentErrorTrack(null);
    return true;
}
 
Example 4
Source File: VideoDialogFragment.java    From TDTChannels-APP with MIT License 6 votes vote down vote up
@Override
public void onPlayerError(ExoPlaybackException error) {
    if (getContext() != null) {
        switch (error.type) {
            case ExoPlaybackException.TYPE_SOURCE:
                Toast.makeText(getContext(), getContext().getString(R.string.channel_detail_source_error_message), Toast.LENGTH_SHORT).show();
                Log.e(TAG, "TYPE_SOURCE: " + error.getSourceException().getMessage());
                break;
            case ExoPlaybackException.TYPE_RENDERER:
                Toast.makeText(getContext(), getContext().getString(R.string.channel_detail_renderer_error_message), Toast.LENGTH_SHORT).show();
                Log.e(TAG, "TYPE_RENDERER: " + error.getRendererException().getMessage());
                break;
            case ExoPlaybackException.TYPE_UNEXPECTED:
                Toast.makeText(getContext(), getContext().getString(R.string.channel_detail_unexpected_error_message), Toast.LENGTH_SHORT).show();
                Log.e(TAG, "TYPE_UNEXPECTED: " + error.getUnexpectedException().getMessage());
                break;
            default:
                Toast.makeText(getContext(), getContext().getString(R.string.channel_detail_unexpected_error_message), Toast.LENGTH_SHORT).show();
                Log.e(TAG, "TYPE_UNKNOWN: " + error.getCause().getMessage());
        }
    }

    if (getActivity() != null) {
        getActivity().onBackPressed();
    }
}
 
Example 5
Source File: ExoMediaPlayer.java    From VideoDemoJava with MIT License 6 votes vote down vote up
@Override
public void onPlayerError(ExoPlaybackException error) {
    PLog.e(TAG,error.getMessage());
    int type = error.type;
    switch (type){
        case ExoPlaybackException.TYPE_SOURCE:
            submitErrorEvent(OnErrorEventListener.ERROR_EVENT_IO, null);
            break;
        case ExoPlaybackException.TYPE_RENDERER:
            submitErrorEvent(OnErrorEventListener.ERROR_EVENT_COMMON, null);
            break;
        case ExoPlaybackException.TYPE_UNEXPECTED:
            submitErrorEvent(OnErrorEventListener.ERROR_EVENT_UNKNOWN, null);
            break;
    }
}
 
Example 6
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 7
Source File: ExoMediaPlayer.java    From PlayerBase with Apache License 2.0 6 votes vote down vote up
@Override
public void onPlayerError(ExoPlaybackException error) {
    if(error==null){
        submitErrorEvent(OnErrorEventListener.ERROR_EVENT_UNKNOWN, null);
        return;
    }
    PLog.e(TAG,error.getMessage()==null?"":error.getMessage());
    int type = error.type;
    switch (type){
        case ExoPlaybackException.TYPE_SOURCE:
            submitErrorEvent(OnErrorEventListener.ERROR_EVENT_IO, null);
            break;
        case ExoPlaybackException.TYPE_RENDERER:
            submitErrorEvent(OnErrorEventListener.ERROR_EVENT_COMMON, null);
            break;
        case ExoPlaybackException.TYPE_UNEXPECTED:
            submitErrorEvent(OnErrorEventListener.ERROR_EVENT_UNKNOWN, null);
            break;
    }
}
 
Example 8
Source File: ExoPlayerErrorMapper.java    From no-player with Apache License 2.0 6 votes vote down vote up
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);
    }
}
 
Example 9
Source File: PlayerEventHandler.java    From zapp with MIT License 6 votes vote down vote up
@Override
public void onPlayerError(EventTime eventTime, ExoPlaybackException error) {
	int errorMessageResourceId = R.string.error_stream_unknown;

	switch (error.type) {
		case ExoPlaybackException.TYPE_SOURCE:
			Timber.e(error, "exo player error TYPE_SOURCE");
			errorMessageResourceId = R.string.error_stream_io;
			break;
		case ExoPlaybackException.TYPE_RENDERER:
			Timber.e(error, "exo player error TYPE_RENDERER");
			errorMessageResourceId = R.string.error_stream_unsupported;
			break;
		case ExoPlaybackException.TYPE_UNEXPECTED:
			Timber.e(error, "exo player error TYPE_UNEXPECTED");
			break;
	}

	errorResourceIdSource.onNext(errorMessageResourceId);
}
 
Example 10
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);
    }
}