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

The following examples show how to use com.google.android.exoplayer2.ExoPlaybackException#TYPE_SOURCE . 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: 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 4
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 5
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 6
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 7
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 8
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 9
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 10
Source File: VodPlaybackFragment.java    From xipl with Apache License 2.0 6 votes vote down vote up
@Override
public void onError(int errorCode, CharSequence errorMessage) {

    // Notify the user if a video can't be played.
    if (errorCode == ExoPlaybackException.TYPE_SOURCE) {
        FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
        ErrorSupportFragment errorFragment = new ErrorSupportFragment();
        errorFragment.setDefaultBackground(true);
        errorFragment.setMessage(getString(R.string.video_not_playable, getProviderName()));
        errorFragment.setImageDrawable(getActivity().getDrawable(R.drawable.lb_ic_sad_cloud));
        fragmentTransaction.replace(R.id.activity_vod_playback_fragment, errorFragment);
        fragmentTransaction.commit();
    }
}
 
Example 11
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 12
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 13
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 14
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 15
Source File: AnalyticsCollector.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
@Override
public final void onPlayerError(ExoPlaybackException error) {
  EventTime eventTime =
      error.type == ExoPlaybackException.TYPE_SOURCE
          ? generateLoadingMediaPeriodEventTime()
          : generatePlayingMediaPeriodEventTime();
  for (AnalyticsListener listener : listeners) {
    listener.onPlayerError(eventTime, error);
  }
}
 
Example 16
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 17
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 18
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 19
Source File: AnalyticsCollector.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
@Override
public final void onPlayerError(ExoPlaybackException error) {
  EventTime eventTime =
      error.type == ExoPlaybackException.TYPE_SOURCE
          ? generateLoadingMediaPeriodEventTime()
          : generatePlayingMediaPeriodEventTime();
  for (AnalyticsListener listener : listeners) {
    listener.onPlayerError(eventTime, error);
  }
}
 
Example 20
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);
    }
}