com.google.android.exoplayer2.ExoPlaybackException类的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(9.0k)|赞(0)|评价(0)|浏览(1173)

本文整理了Java中com.google.android.exoplayer2.ExoPlaybackException类的一些代码示例,展示了ExoPlaybackException类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ExoPlaybackException类的具体详情如下:
包路径:com.google.android.exoplayer2.ExoPlaybackException
类名称:ExoPlaybackException

ExoPlaybackException介绍

[英]Thrown when a non-recoverable playback failure occurs.
[中]发生不可恢复播放故障时引发。

代码示例

代码示例来源:origin: google/ExoPlayer

private void processEndOfStream() throws ExoPlaybackException {
 outputStreamEnded = true;
 try {
  audioSink.playToEndOfStream();
 } catch (AudioSink.WriteException e) {
  throw ExoPlaybackException.createForRenderer(e, getIndex());
 }
}

代码示例来源:origin: jiajunhui/PlayerBase

@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;
  }
}

代码示例来源:origin: google/ExoPlayer

/**
 * Notifies the media clock that a renderer has been enabled. Starts using the media clock of the
 * provided renderer if available.
 *
 * @param renderer The renderer which has been enabled.
 * @throws ExoPlaybackException If the renderer provides a media clock and another renderer media
 *     clock is already provided.
 */
public void onRendererEnabled(Renderer renderer) throws ExoPlaybackException {
 MediaClock rendererMediaClock = renderer.getMediaClock();
 if (rendererMediaClock != null && rendererMediaClock != rendererClock) {
  if (rendererClock != null) {
   throw ExoPlaybackException.createForUnexpected(
     new IllegalStateException("Multiple renderer media clocks enabled."));
  }
  this.rendererClock = rendererMediaClock;
  this.rendererClockSource = renderer;
  rendererClock.setPlaybackParameters(standaloneMediaClock.getPlaybackParameters());
  ensureSynced();
 }
}

代码示例来源:origin: lizixian18/StarrySky

@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;
  }
  if (mCallback != null) {
    mCallback.onError("ExoPlayer error " + what);
  }
}

代码示例来源:origin: novoda/no-player

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);
    }
  }
}

代码示例来源:origin: google/ExoPlayer

new ActionSchedule.Builder("AnalyticsCollectorTest")
  .waitForPlaybackState(Player.STATE_READY)
  .throwPlaybackException(ExoPlaybackException.createForSource(new IOException()))
  .waitForPlaybackState(Player.STATE_IDLE)
  .prepareSource(mediaSource, /* resetPosition= */ false, /* resetState= */ false)

代码示例来源:origin: google/ExoPlayer

} catch (ExoPlaybackException e) {
 assertThat(e.getUnexpectedException()).isInstanceOf(IllegalSeekPositionException.class);

代码示例来源:origin: TeamNewPipe/NewPipe

processSourceError(error.getSourceException());
showStreamError(error);
break;

代码示例来源:origin: google/ExoPlayer

Log.e(TAG, "Source error.", e);
 stopInternal(/* reset= */ false, /* acknowledgeStop= */ false);
 eventHandler.obtainMessage(MSG_ERROR, ExoPlaybackException.createForSource(e)).sendToTarget();
 maybeNotifyPlaybackInfoChanged();
} catch (RuntimeException e) {
 Log.e(TAG, "Internal runtime error.", e);
 stopInternal(/* reset= */ false, /* acknowledgeStop= */ false);
 eventHandler.obtainMessage(MSG_ERROR, ExoPlaybackException.createForUnexpected(e))
   .sendToTarget();
 maybeNotifyPlaybackInfoChanged();

代码示例来源:origin: yuliskov/SmartYouTubeTV

String errorString = null;
if (e.type == ExoPlaybackException.TYPE_RENDERER) {
  Exception cause = e.getRendererException();
  if (cause instanceof DecoderInitializationException) {

代码示例来源:origin: lipangit/JiaoZiVideoPlayer

@Override
public void onPlayerError(ExoPlaybackException error) {
  Log.e(TAG, "onPlayerError" + error.toString());
  JZMediaManager.instance().mainThreadHandler.post(() -> {
    if (JzvdMgr.getCurrentJzvd() != null) {
      JzvdMgr.getCurrentJzvd().onError(1000, 1000);
    }
  });
}

代码示例来源:origin: huyongli/TigerVideo

@Override
public void onPlayerError(ExoPlaybackException error) {
  if (mPlayCallback != null) {
    mPlayCallback.onError(error.getCause().toString());
  }
}

代码示例来源:origin: fennifith/Alarmio

@Override
public void onPlayerError(ExoPlaybackException error) {
  currentStream = null;
  Exception exception;
  switch (error.type) {
    case ExoPlaybackException.TYPE_RENDERER:
      exception = error.getRendererException();
      break;
    case ExoPlaybackException.TYPE_SOURCE:
      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();
}

代码示例来源:origin: google/ExoPlayer

.pause()
.waitForPlaybackState(Player.STATE_READY)
.throwPlaybackException(ExoPlaybackException.createForSource(new IOException()))
.waitForPlaybackState(Player.STATE_IDLE)
.prepareSource(mediaSource2, /* resetPosition= */ false, /* resetState= */ false)
.waitForPlaybackState(Player.STATE_BUFFERING)
.throwPlaybackException(ExoPlaybackException.createForSource(new IOException()))
.waitForPlaybackState(Player.STATE_IDLE)
.build();

代码示例来源:origin: google/ExoPlayer

} catch (ExoPlaybackException e) {
 assertThat(e.getUnexpectedException()).isInstanceOf(IllegalSeekPositionException.class);

代码示例来源:origin: yuliskov/SmartYouTubeTV

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;
}

代码示例来源:origin: novoda/no-player

@Override
public void onPlayerError(EventTime eventTime, ExoPlaybackException error) {
  HashMap<String, String> callingMethodParameters = new HashMap<>();
  callingMethodParameters.put(Parameters.EVENT_TIME, eventTime.toString());
  callingMethodParameters.put(Parameters.ERROR, error.toString());
  infoListeners.onNewInfo(Methods.ON_PLAYER_ERROR, callingMethodParameters);
}

代码示例来源:origin: y20k/transistor

@Override
public void onPlayerError(ExoPlaybackException error) {
  switch (error.type) {
    case TYPE_RENDERER:
      // error occurred in a Renderer
      LogHelper.e(LOG_TAG, "An error occurred. Type RENDERER: " + error.getRendererException().toString());
      break;
    case TYPE_SOURCE:
      // error occurred loading data from a MediaSource.
      LogHelper.e(LOG_TAG, "An error occurred. Type SOURCE: " + error.getSourceException().toString());
      break;
    case TYPE_UNEXPECTED:
      // error was an unexpected RuntimeException.
      LogHelper.e(LOG_TAG, "An error occurred. Type UNEXPECTED: " + error.getUnexpectedException().toString());
      break;
    default:
      LogHelper.w(LOG_TAG, "An error occurred. Type OTHER ERROR.");
      break;
  }
}

代码示例来源:origin: google/ExoPlayer

@Override
public final int supportsFormat(Format format) throws ExoPlaybackException {
 try {
  return supportsFormat(mediaCodecSelector, drmSessionManager, format);
 } catch (DecoderQueryException e) {
  throw ExoPlaybackException.createForRenderer(e, getIndex());
 }
}

代码示例来源:origin: google/ExoPlayer

@Test
public void testAttachAndCallbacksAfterRelease() {
 setupPlayback(CONTENT_TIMELINE, PREROLL_ADS_DURATIONS_US, PREROLL_CUE_POINTS_SECONDS);
 imaAdsLoader.release();
 imaAdsLoader.attachPlayer(fakeExoPlayer, adsLoaderListener, adUiViewGroup);
 fakeExoPlayer.setPlayingContentPosition(/* position= */ 0);
 fakeExoPlayer.setState(Player.STATE_READY, true);
 // If callbacks are invoked there is no crash.
 // Note: we can't currently call getContentProgress/getAdProgress as a VerifyError is thrown
 // when using Robolectric and accessing VideoProgressUpdate.VIDEO_TIME_NOT_READY, due to the IMA
 // SDK being proguarded.
 imaAdsLoader.requestAds(adUiViewGroup);
 imaAdsLoader.onAdEvent(getAdEvent(AdEventType.LOADED, UNSKIPPABLE_AD));
 imaAdsLoader.loadAd(TEST_URI.toString());
 imaAdsLoader.onAdEvent(getAdEvent(AdEventType.CONTENT_PAUSE_REQUESTED, UNSKIPPABLE_AD));
 imaAdsLoader.playAd();
 imaAdsLoader.onAdEvent(getAdEvent(AdEventType.STARTED, UNSKIPPABLE_AD));
 imaAdsLoader.pauseAd();
 imaAdsLoader.stopAd();
 imaAdsLoader.onPlayerError(ExoPlaybackException.createForSource(new IOException()));
 imaAdsLoader.onPositionDiscontinuity(Player.DISCONTINUITY_REASON_SEEK);
 imaAdsLoader.onAdEvent(getAdEvent(AdEventType.CONTENT_RESUME_REQUESTED, /* ad= */ null));
 imaAdsLoader.handlePrepareError(
   /* adGroupIndex= */ 0, /* adIndexInAdGroup= */ 0, new IOException());
}

相关文章