当前位置: 首页>>代码示例>>Java>>正文


Java ExoPlaybackException类代码示例

本文整理汇总了Java中com.google.android.exoplayer2.ExoPlaybackException的典型用法代码示例。如果您正苦于以下问题:Java ExoPlaybackException类的具体用法?Java ExoPlaybackException怎么用?Java ExoPlaybackException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ExoPlaybackException类属于com.google.android.exoplayer2包,在下文中一共展示了ExoPlaybackException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: selectTracks

import com.google.android.exoplayer2.ExoPlaybackException; //导入依赖的package包/类
@Override
protected TrackSelection[] selectTracks(RendererCapabilities[] rendererCapabilities,
    TrackGroupArray[] rendererTrackGroupArrays, int[][][] rendererFormatSupports)
    throws ExoPlaybackException {
  Assertions.checkState(rendererCapabilities[VIDEO_RENDERER_INDEX].getTrackType()
      == C.TRACK_TYPE_VIDEO);
  Assertions.checkState(rendererCapabilities[AUDIO_RENDERER_INDEX].getTrackType()
      == C.TRACK_TYPE_AUDIO);
  Assertions.checkState(rendererTrackGroupArrays[VIDEO_RENDERER_INDEX].length == 1);
  Assertions.checkState(rendererTrackGroupArrays[AUDIO_RENDERER_INDEX].length == 1);
  TrackSelection[] selections = new TrackSelection[rendererCapabilities.length];
  selections[VIDEO_RENDERER_INDEX] = new RandomTrackSelection(
      rendererTrackGroupArrays[VIDEO_RENDERER_INDEX].get(0),
      getVideoTrackIndices(rendererTrackGroupArrays[VIDEO_RENDERER_INDEX].get(0),
          rendererFormatSupports[VIDEO_RENDERER_INDEX][0], videoFormatIds,
          canIncludeAdditionalVideoFormats),
      0 /* seed */);
  selections[AUDIO_RENDERER_INDEX] = new FixedTrackSelection(
      rendererTrackGroupArrays[AUDIO_RENDERER_INDEX].get(0),
      getTrackIndex(rendererTrackGroupArrays[AUDIO_RENDERER_INDEX].get(0), audioFormatId));
  includedAdditionalVideoFormats =
      selections[VIDEO_RENDERER_INDEX].length() > videoFormatIds.length;
  return selections;
}
 
开发者ID:ashwanijanghu,项目名称:ExoPlayer-Offline,代码行数:25,代码来源:DashTest.java

示例2: onPlayerError

import com.google.android.exoplayer2.ExoPlaybackException; //导入依赖的package包/类
@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;
    }

}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:25,代码来源:PlayerService.java

示例3: selectVideoTrack

import com.google.android.exoplayer2.ExoPlaybackException; //导入依赖的package包/类
protected TrackSelection selectVideoTrack(RendererCapabilities rendererCapabilities,
    TrackGroupArray groups, int[][] formatSupport, int maxVideoWidth, int maxVideoHeight,
    int maxVideoBitrate, boolean allowNonSeamlessAdaptiveness, boolean allowMixedMimeAdaptiveness,
    int viewportWidth, int viewportHeight, boolean orientationMayChange,
    TrackSelection.Factory adaptiveTrackSelectionFactory, boolean exceedConstraintsIfNecessary,
    boolean exceedRendererCapabilitiesIfNecessary) throws ExoPlaybackException {
  TrackSelection selection = null;
  if (adaptiveTrackSelectionFactory != null) {
    selection = selectAdaptiveVideoTrack(rendererCapabilities, groups, formatSupport,
        maxVideoWidth, maxVideoHeight, maxVideoBitrate, allowNonSeamlessAdaptiveness,
        allowMixedMimeAdaptiveness, viewportWidth, viewportHeight,
        orientationMayChange, adaptiveTrackSelectionFactory);
  }
  if (selection == null) {
    selection = selectFixedVideoTrack(groups, formatSupport, maxVideoWidth, maxVideoHeight,
        maxVideoBitrate, viewportWidth, viewportHeight, orientationMayChange,
        exceedConstraintsIfNecessary, exceedRendererCapabilitiesIfNecessary);
  }
  return selection;
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:21,代码来源:DefaultTrackSelector.java

示例4: selectAdaptiveVideoTrack

import com.google.android.exoplayer2.ExoPlaybackException; //导入依赖的package包/类
private static TrackSelection selectAdaptiveVideoTrack(RendererCapabilities rendererCapabilities,
    TrackGroupArray groups, int[][] formatSupport, int maxVideoWidth, int maxVideoHeight,
    int maxVideoBitrate, boolean allowNonSeamlessAdaptiveness, boolean allowMixedMimeAdaptiveness,
    int viewportWidth, int viewportHeight, boolean orientationMayChange,
    TrackSelection.Factory adaptiveTrackSelectionFactory) throws ExoPlaybackException {
  int requiredAdaptiveSupport = allowNonSeamlessAdaptiveness
      ? (RendererCapabilities.ADAPTIVE_NOT_SEAMLESS | RendererCapabilities.ADAPTIVE_SEAMLESS)
      : RendererCapabilities.ADAPTIVE_SEAMLESS;
  boolean allowMixedMimeTypes = allowMixedMimeAdaptiveness
      && (rendererCapabilities.supportsMixedMimeTypeAdaptation() & requiredAdaptiveSupport) != 0;
  for (int i = 0; i < groups.length; i++) {
    TrackGroup group = groups.get(i);
    int[] adaptiveTracks = getAdaptiveVideoTracksForGroup(group, formatSupport[i],
        allowMixedMimeTypes, requiredAdaptiveSupport, maxVideoWidth, maxVideoHeight,
        maxVideoBitrate, viewportWidth, viewportHeight, orientationMayChange);
    if (adaptiveTracks.length > 0) {
      return adaptiveTrackSelectionFactory.createTrackSelection(group, adaptiveTracks);
    }
  }
  return null;
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:22,代码来源:DefaultTrackSelector.java

示例5: findRenderer

import com.google.android.exoplayer2.ExoPlaybackException; //导入依赖的package包/类
/**
 * Finds the renderer to which the provided {@link TrackGroup} should be associated.
 * <p>
 * A {@link TrackGroup} is associated to a renderer that reports
 * {@link RendererCapabilities#FORMAT_HANDLED} support for one or more of the tracks in the group,
 * or {@link RendererCapabilities#FORMAT_EXCEEDS_CAPABILITIES} if no such renderer exists, or
 * {@link RendererCapabilities#FORMAT_UNSUPPORTED_SUBTYPE} if again no such renderer exists. In
 * the case that two or more renderers report the same level of support, the renderer with the
 * lowest index is associated.
 * <p>
 * If all renderers report {@link RendererCapabilities#FORMAT_UNSUPPORTED_TYPE} for all of the
 * tracks in the group, then {@code renderers.length} is returned to indicate that no association
 * was made.
 *
 * @param rendererCapabilities The {@link RendererCapabilities} of the renderers.
 * @param group The {@link TrackGroup} whose associated renderer is to be found.
 * @return The index of the associated renderer, or {@code renderers.length} if no
 *     association was made.
 * @throws ExoPlaybackException If an error occurs finding a renderer.
 */
private static int findRenderer(RendererCapabilities[] rendererCapabilities, TrackGroup group)
    throws ExoPlaybackException {
  int bestRendererIndex = rendererCapabilities.length;
  int bestFormatSupportLevel = RendererCapabilities.FORMAT_UNSUPPORTED_TYPE;
  for (int rendererIndex = 0; rendererIndex < rendererCapabilities.length; rendererIndex++) {
    RendererCapabilities rendererCapability = rendererCapabilities[rendererIndex];
    for (int trackIndex = 0; trackIndex < group.length; trackIndex++) {
      int formatSupportLevel = rendererCapability.supportsFormat(group.getFormat(trackIndex))
          & RendererCapabilities.FORMAT_SUPPORT_MASK;
      if (formatSupportLevel > bestFormatSupportLevel) {
        bestRendererIndex = rendererIndex;
        bestFormatSupportLevel = formatSupportLevel;
        if (bestFormatSupportLevel == RendererCapabilities.FORMAT_HANDLED) {
          // We can't do better.
          return bestRendererIndex;
        }
      }
    }
  }
  return bestRendererIndex;
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:42,代码来源:MappingTrackSelector.java

示例6: onOutputFormatChanged

import com.google.android.exoplayer2.ExoPlaybackException; //导入依赖的package包/类
@Override
protected void onOutputFormatChanged(MediaCodec codec, MediaFormat outputFormat)
    throws ExoPlaybackException {
  boolean passthrough = passthroughMediaFormat != null;
  String mimeType = passthrough ? passthroughMediaFormat.getString(MediaFormat.KEY_MIME)
      : MimeTypes.AUDIO_RAW;
  MediaFormat format = passthrough ? passthroughMediaFormat : outputFormat;
  int channelCount = format.getInteger(MediaFormat.KEY_CHANNEL_COUNT);
  int sampleRate = format.getInteger(MediaFormat.KEY_SAMPLE_RATE);
  int[] channelMap;
  if (codecNeedsDiscardChannelsWorkaround && channelCount == 6 && this.channelCount < 6) {
    channelMap = new int[this.channelCount];
    for (int i = 0; i < this.channelCount; i++) {
      channelMap[i] = i;
    }
  } else {
    channelMap = null;
  }

  try {
    audioTrack.configure(mimeType, channelCount, sampleRate, pcmEncoding, 0, channelMap);
  } catch (AudioTrack.ConfigurationException e) {
    throw ExoPlaybackException.createForRenderer(e, getIndex());
  }
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:26,代码来源:MediaCodecAudioRenderer.java

示例7: onPlayerError

import com.google.android.exoplayer2.ExoPlaybackException; //导入依赖的package包/类
@Override
public void onPlayerError(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;
	}

	listener.onVideoError(errorMessageResourceId);
}
 
开发者ID:cemrich,项目名称:zapp,代码行数:21,代码来源:VideoErrorHandler.java

示例8: selectVideoTrack

import com.google.android.exoplayer2.ExoPlaybackException; //导入依赖的package包/类
protected TrackSelection selectVideoTrack(RendererCapabilities rendererCapabilities,
    TrackGroupArray groups, int[][] formatSupport, int maxVideoWidth, int maxVideoHeight,
    int maxVideoBitrate, boolean allowNonSeamlessAdaptiveness, boolean allowMixedMimeAdaptiveness,
    int viewportWidth, int viewportHeight, boolean orientationMayChange,
    TrackSelection.Factory adaptiveVideoTrackSelectionFactory,
    boolean exceedConstraintsIfNecessary, boolean exceedRendererCapabilitiesIfNecessary)
    throws ExoPlaybackException {
  TrackSelection selection = null;
  if (adaptiveVideoTrackSelectionFactory != null) {
    selection = selectAdaptiveVideoTrack(rendererCapabilities, groups, formatSupport,
        maxVideoWidth, maxVideoHeight, maxVideoBitrate, allowNonSeamlessAdaptiveness,
        allowMixedMimeAdaptiveness, viewportWidth, viewportHeight,
        orientationMayChange, adaptiveVideoTrackSelectionFactory);
  }
  if (selection == null) {
    selection = selectFixedVideoTrack(groups, formatSupport, maxVideoWidth, maxVideoHeight,
        maxVideoBitrate, viewportWidth, viewportHeight, orientationMayChange,
        exceedConstraintsIfNecessary, exceedRendererCapabilitiesIfNecessary);
  }
  return selection;
}
 
开发者ID:jcodeing,项目名称:K-Sonic,代码行数:22,代码来源:DefaultTrackSelector.java

示例9: render

import com.google.android.exoplayer2.ExoPlaybackException; //导入依赖的package包/类
@Override
public void render(long positionUs, long elapsedRealtimeUs) throws ExoPlaybackException {
  if (format == null) {
    readFormat();
  }
  maybeInitCodec();
  if (codec != null) {
    TraceUtil.beginSection("drainAndFeed");
    while (drainOutputBuffer(positionUs, elapsedRealtimeUs)) {}
    while (feedInputBuffer()) {}
    TraceUtil.endSection();
  } else if (format != null) {
    skipToKeyframeBefore(positionUs);
  }
  decoderCounters.ensureUpdated();
}
 
开发者ID:zhanglibin123488,项目名称:videoPickPlayer,代码行数:17,代码来源:MediaCodecRenderer.java

示例10: handleMessage

import com.google.android.exoplayer2.ExoPlaybackException; //导入依赖的package包/类
@Override
public void handleMessage(int messageType, Object message) throws ExoPlaybackException {
  switch (messageType) {
    case C.MSG_SET_VOLUME:
      audioTrack.setVolume((Float) message);
      break;
    case C.MSG_SET_PLAYBACK_PARAMS:
      audioTrack.setPlaybackParams((PlaybackParams) message);
      break;
    case C.MSG_SET_STREAM_TYPE:
      @C.StreamType int streamType = (Integer) message;
      audioTrack.setStreamType(streamType);
      break;
    default:
      super.handleMessage(messageType, message);
      break;
  }
}
 
开发者ID:jcodeing,项目名称:K-Sonic,代码行数:19,代码来源:SimpleDecoderAudioRenderer.java

示例11: setSurface

import com.google.android.exoplayer2.ExoPlaybackException; //导入依赖的package包/类
private void setSurface(Surface surface) throws ExoPlaybackException {
  // We only need to update the codec if the surface has changed.
  if (this.surface != surface) {
    this.surface = surface;
    int state = getState();
    if (state == STATE_ENABLED || state == STATE_STARTED) {
      MediaCodec codec = getCodec();
      if (Util.SDK_INT >= 23 && codec != null && surface != null) {
        setOutputSurfaceV23(codec, surface);
      } else {
        releaseCodec();
        maybeInitCodec();
      }
    }
  }
  // Clear state so that we always call the event listener with the video size and when a frame
  // is rendered, even if the surface hasn't changed.
  clearRenderedFirstFrame();
  clearLastReportedVideoSize();
}
 
开发者ID:jcodeing,项目名称:K-Sonic,代码行数:21,代码来源:MediaCodecVideoRenderer.java

示例12: selectAdaptiveVideoTrack

import com.google.android.exoplayer2.ExoPlaybackException; //导入依赖的package包/类
private static TrackSelection selectAdaptiveVideoTrack(RendererCapabilities rendererCapabilities,
    TrackGroupArray groups, int[][] formatSupport, int maxVideoWidth, int maxVideoHeight,
    boolean allowNonSeamlessAdaptiveness, boolean allowMixedMimeAdaptiveness, int viewportWidth,
    int viewportHeight, boolean orientationMayChange,
    TrackSelection.Factory adaptiveVideoTrackSelectionFactory) throws ExoPlaybackException {
  int requiredAdaptiveSupport = allowNonSeamlessAdaptiveness
      ? (RendererCapabilities.ADAPTIVE_NOT_SEAMLESS | RendererCapabilities.ADAPTIVE_SEAMLESS)
      : RendererCapabilities.ADAPTIVE_SEAMLESS;
  boolean allowMixedMimeTypes = allowMixedMimeAdaptiveness
      && (rendererCapabilities.supportsMixedMimeTypeAdaptation() & requiredAdaptiveSupport) != 0;
  for (int i = 0; i < groups.length; i++) {
    TrackGroup group = groups.get(i);
    int[] adaptiveTracks = getAdaptiveTracksForGroup(group, formatSupport[i],
        allowMixedMimeTypes, requiredAdaptiveSupport, maxVideoWidth, maxVideoHeight,
        viewportWidth, viewportHeight, orientationMayChange);
    if (adaptiveTracks.length > 0) {
      return adaptiveVideoTrackSelectionFactory.createTrackSelection(group, adaptiveTracks);
    }
  }
  return null;
}
 
开发者ID:zhanglibin123488,项目名称:videoPickPlayer,代码行数:22,代码来源:DefaultTrackSelector.java

示例13: findRenderer

import com.google.android.exoplayer2.ExoPlaybackException; //导入依赖的package包/类
/**
 * Finds the renderer to which the provided {@link TrackGroup} should be associated.
 * <p>
 * A {@link TrackGroup} is associated to a renderer that reports
 * {@link RendererCapabilities#FORMAT_HANDLED} support for one or more of the tracks in the group,
 * or {@link RendererCapabilities#FORMAT_EXCEEDS_CAPABILITIES} if no such renderer exists, or
 * {@link RendererCapabilities#FORMAT_UNSUPPORTED_SUBTYPE} if again no such renderer exists. In
 * the case that two or more renderers report the same level of support, the renderer with the
 * lowest index is associated.
 * <p>
 * If all renderers report {@link RendererCapabilities#FORMAT_UNSUPPORTED_TYPE} for all of the
 * tracks in the group, then {@code renderers.length} is returned to indicate that no association
 * was made.
 *
 * @param rendererCapabilities The {@link RendererCapabilities} of the renderers.
 * @param group The {@link TrackGroup} whose associated renderer is to be found.
 * @return The index of the associated renderer, or {@code renderers.length} if no
 *     association was made.
 * @throws ExoPlaybackException If an error occurs finding a renderer.
 */
private static int findRenderer(RendererCapabilities[] rendererCapabilities, TrackGroup group)
    throws ExoPlaybackException {
  int bestRendererIndex = rendererCapabilities.length;
  int bestSupportLevel = RendererCapabilities.FORMAT_UNSUPPORTED_TYPE;
  for (int rendererIndex = 0; rendererIndex < rendererCapabilities.length; rendererIndex++) {
    RendererCapabilities rendererCapability = rendererCapabilities[rendererIndex];
    for (int trackIndex = 0; trackIndex < group.length; trackIndex++) {
      int trackSupportLevel = rendererCapability.supportsFormat(group.getFormat(trackIndex));
      if (trackSupportLevel > bestSupportLevel) {
        bestRendererIndex = rendererIndex;
        bestSupportLevel = trackSupportLevel;
        if (bestSupportLevel == RendererCapabilities.FORMAT_HANDLED) {
          // We can't do better.
          return bestRendererIndex;
        }
      }
    }
  }
  return bestRendererIndex;
}
 
开发者ID:zhanglibin123488,项目名称:videoPickPlayer,代码行数:41,代码来源:MappingTrackSelector.java

示例14: render

import com.google.android.exoplayer2.ExoPlaybackException; //导入依赖的package包/类
@Override
public void render(long positionUs, long elapsedRealtimeUs) throws ExoPlaybackException {
  if (!inputStreamEnded && pendingMetadata == null) {
    buffer.clear();
    int result = readSource(formatHolder, buffer);
    if (result == C.RESULT_BUFFER_READ) {
      if (buffer.isEndOfStream()) {
        inputStreamEnded = true;
      } else {
        pendingMetadataTimestamp = buffer.timeUs;
        try {
          buffer.flip();
          ByteBuffer bufferData = buffer.data;
          pendingMetadata = metadataDecoder.decode(bufferData.array(), bufferData.limit());
        } catch (MetadataDecoderException e) {
          throw ExoPlaybackException.createForRenderer(e, getIndex());
        }
      }
    }
  }

  if (pendingMetadata != null && pendingMetadataTimestamp <= positionUs) {
    invokeRenderer(pendingMetadata);
    pendingMetadata = null;
  }
}
 
开发者ID:zhanglibin123488,项目名称:videoPickPlayer,代码行数:27,代码来源:MetadataRenderer.java

示例15: onPlayerError

import com.google.android.exoplayer2.ExoPlaybackException; //导入依赖的package包/类
@Override
public void onPlayerError(ExoPlaybackException e) {
    String errorString = null;
    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 = 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.decoderName);
            }
        }
    }
    if (errorString != null) {
        eventEmitter.error(errorString, e);
    }
    playerNeedsSource = true;
}
 
开发者ID:12d,项目名称:react-native-videoplayer,代码行数:31,代码来源:ReactExoplayerView.java


注:本文中的com.google.android.exoplayer2.ExoPlaybackException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。