Java源码示例:com.google.android.exoplayer.MediaCodecUtil.DecoderQueryException

示例1
@Override
public void onError(Exception e) {
    String errorString = null;
    if (e instanceof UnsupportedDrmException) {
        // Special case DRM failures.
        UnsupportedDrmException unsupportedDrmException = (UnsupportedDrmException) e;
        errorString = getString(Util.SDK_INT < 18 ? R.string.video_error_drm_not_supported
                : unsupportedDrmException.reason == UnsupportedDrmException.REASON_UNSUPPORTED_SCHEME
                ? R.string.video_error_drm_unsupported_scheme : R.string.video_error_drm_unknown);
    } else if (e instanceof ExoPlaybackException
            && e.getCause() instanceof DecoderInitializationException) {
        // Special case for decoder initialization failures.
        DecoderInitializationException decoderInitializationException =
                (DecoderInitializationException) e.getCause();
        if (decoderInitializationException.decoderName == null) {
            if (decoderInitializationException.getCause() instanceof DecoderQueryException) {
                errorString = getString(R.string.video_error_querying_decoders);
            } else if (decoderInitializationException.secureDecoderRequired) {
                errorString = getString(R.string.video_error_no_secure_decoder,
                        decoderInitializationException.mimeType);
            } else {
                errorString = getString(R.string.video_error_no_decoder,
                        decoderInitializationException.mimeType);
            }
        } else {
            errorString = getString(R.string.video_error_instantiating_decoder,
                    decoderInitializationException.decoderName);
        }
    }
    if (errorString != null) {
        Toast.makeText(getApplicationContext(), errorString, Toast.LENGTH_LONG).show();
    }
    playerNeedsPrepare = true;
    showControls();
}
 
示例2
@Override
public void onError(Exception e) {
    String errorString = null;
    if (e instanceof UnsupportedDrmException) {
        // Special case DRM failures.
        UnsupportedDrmException unsupportedDrmException = (UnsupportedDrmException) e;
        errorString = getString(Util.SDK_INT < 18 ? R.string.error_drm_not_supported
                : unsupportedDrmException.reason == UnsupportedDrmException.REASON_UNSUPPORTED_SCHEME
                ? R.string.error_drm_unsupported_scheme : R.string.error_drm_unknown);
    } else if (e instanceof ExoPlaybackException
            && e.getCause() instanceof DecoderInitializationException) {
        // Special case for decoder initialization failures.
        DecoderInitializationException decoderInitializationException =
                (DecoderInitializationException) e.getCause();
        if (decoderInitializationException.decoderName == null) {
            if (decoderInitializationException.getCause() instanceof DecoderQueryException) {
                errorString = getString(R.string.error_querying_decoders);
            } else if (decoderInitializationException.secureDecoderRequired) {
                errorString = getString(R.string.error_no_secure_decoder,
                        decoderInitializationException.mimeType);
            } else {
                errorString = getString(R.string.error_no_decoder,
                        decoderInitializationException.mimeType);
            }
        } else {
            errorString = getString(R.string.error_instantiating_decoder,
                    decoderInitializationException.decoderName);
        }
    }
    if (errorString != null) {
        Toast.makeText(getApplicationContext(), errorString, Toast.LENGTH_LONG).show();
    }
    playerNeedsPrepare = true;
    updateButtonVisibilities();
    showControls();
}
 
示例3
@Override
public void onError(Exception e) {
    String errorString = null;
    if (e instanceof UnsupportedDrmException) {
        // Special case DRM failures.
        UnsupportedDrmException unsupportedDrmException = (UnsupportedDrmException) e;
        errorString = getString(Util.SDK_INT < 18 ? R.string.video_error_drm_not_supported
                : unsupportedDrmException.reason == UnsupportedDrmException.REASON_UNSUPPORTED_SCHEME
                ? R.string.video_error_drm_unsupported_scheme : R.string.video_error_drm_unknown);
    } else if (e instanceof ExoPlaybackException
            && e.getCause() instanceof DecoderInitializationException) {
        // Special case for decoder initialization failures.
        DecoderInitializationException decoderInitializationException =
                (DecoderInitializationException) e.getCause();
        if (decoderInitializationException.decoderName == null) {
            if (decoderInitializationException.getCause() instanceof DecoderQueryException) {
                errorString = getString(R.string.video_error_querying_decoders);
            } else if (decoderInitializationException.secureDecoderRequired) {
                errorString = getString(R.string.video_error_no_secure_decoder,
                        decoderInitializationException.mimeType);
            } else {
                errorString = getString(R.string.video_error_no_decoder,
                        decoderInitializationException.mimeType);
            }
        } else {
            errorString = getString(R.string.video_error_instantiating_decoder,
                    decoderInitializationException.decoderName);
        }
    }
    if (errorString != null) {
        Toast.makeText(getApplicationContext(), errorString, Toast.LENGTH_LONG).show();
    }
    playerNeedsPrepare = true;
    showControls();
}
 
示例4
@Override
public void onSingleManifest(HlsPlaylist manifest) {
  if (canceled) {
    return;
  }

  Handler mainHandler = player.getMainHandler();
  LoadControl loadControl = new DefaultLoadControl(new DefaultAllocator(BUFFER_SEGMENT_SIZE));
  DefaultBandwidthMeter bandwidthMeter = new DefaultBandwidthMeter();

  int[] variantIndices = null;
  if (manifest instanceof HlsMasterPlaylist) {
    HlsMasterPlaylist masterPlaylist = (HlsMasterPlaylist) manifest;
    try {
      variantIndices = VideoFormatSelectorUtil.selectVideoFormatsForDefaultDisplay(
          context, masterPlaylist.variants, null, false);
    } catch (DecoderQueryException e) {
      player.onRenderersError(e);
      return;
    }
    if (variantIndices.length == 0) {
      player.onRenderersError(new IllegalStateException("No variants selected."));
      return;
    }
  }

  DataSource dataSource = new DefaultUriDataSource(context, bandwidthMeter, userAgent);
  HlsChunkSource chunkSource = new HlsChunkSource(dataSource, url, manifest, bandwidthMeter,
      variantIndices, HlsChunkSource.ADAPTIVE_MODE_SPLICE);
  HlsSampleSource sampleSource = new HlsSampleSource(chunkSource, loadControl,
      BUFFER_SEGMENTS * BUFFER_SEGMENT_SIZE, mainHandler, player, DemoPlayer.TYPE_VIDEO);
  MediaCodecVideoTrackRenderer videoRenderer = new MediaCodecVideoTrackRenderer(context,
      sampleSource, MediaCodec.VIDEO_SCALING_MODE_SCALE_TO_FIT, 5000, mainHandler, player, 50);
  MediaCodecAudioTrackRenderer audioRenderer = new MediaCodecAudioTrackRenderer(sampleSource,
      null, true, player.getMainHandler(), player, AudioCapabilities.getCapabilities(context));
  MetadataTrackRenderer<Map<String, Object>> id3Renderer = new MetadataTrackRenderer<>(
      sampleSource, new Id3Parser(), player, mainHandler.getLooper());
  Eia608TrackRenderer closedCaptionRenderer = new Eia608TrackRenderer(sampleSource, player,
      mainHandler.getLooper());

  TrackRenderer[] renderers = new TrackRenderer[DemoPlayer.RENDERER_COUNT];
  renderers[DemoPlayer.TYPE_VIDEO] = videoRenderer;
  renderers[DemoPlayer.TYPE_AUDIO] = audioRenderer;
  renderers[DemoPlayer.TYPE_METADATA] = id3Renderer;
  renderers[DemoPlayer.TYPE_TEXT] = closedCaptionRenderer;
  player.onRenderers(renderers, bandwidthMeter);
}
 
示例5
@Override
public void onSingleManifest(HlsPlaylist manifest) {
  if (canceled) {
    return;
  }

  Handler mainHandler = player.getMainHandler();
  LoadControl loadControl = new DefaultLoadControl(new DefaultAllocator(BUFFER_SEGMENT_SIZE));
  DefaultBandwidthMeter bandwidthMeter = new DefaultBandwidthMeter();

  int[] variantIndices = null;
  if (manifest instanceof HlsMasterPlaylist) {
    HlsMasterPlaylist masterPlaylist = (HlsMasterPlaylist) manifest;
    try {
      variantIndices = VideoFormatSelectorUtil.selectVideoFormatsForDefaultDisplay(
          context, masterPlaylist.variants, null, false);
    } catch (DecoderQueryException e) {
      player.onRenderersError(e);
      return;
    }
    if (variantIndices.length == 0) {
      player.onRenderersError(new IllegalStateException("No variants selected."));
      return;
    }
  }

  DataSource dataSource = new DefaultUriDataSource(context, bandwidthMeter, userAgent);
  HlsChunkSource chunkSource = new HlsChunkSource(dataSource, url, manifest, bandwidthMeter,
      variantIndices, HlsChunkSource.ADAPTIVE_MODE_SPLICE);
  HlsSampleSource sampleSource = new HlsSampleSource(chunkSource, loadControl,
      BUFFER_SEGMENTS * BUFFER_SEGMENT_SIZE, mainHandler, player, DemoPlayer.TYPE_VIDEO);
  MediaCodecVideoTrackRenderer videoRenderer = new MediaCodecVideoTrackRenderer(context,
      sampleSource, MediaCodec.VIDEO_SCALING_MODE_SCALE_TO_FIT, 5000, mainHandler, player, 50);
  MediaCodecAudioTrackRenderer audioRenderer = new MediaCodecAudioTrackRenderer(sampleSource,
      null, true, player.getMainHandler(), player, AudioCapabilities.getCapabilities(context));
  MetadataTrackRenderer<Map<String, Object>> id3Renderer = new MetadataTrackRenderer<>(
      sampleSource, new Id3Parser(), player, mainHandler.getLooper());
  Eia608TrackRenderer closedCaptionRenderer = new Eia608TrackRenderer(sampleSource, player,
      mainHandler.getLooper());

  TrackRenderer[] renderers = new TrackRenderer[DemoPlayer.RENDERER_COUNT];
  renderers[DemoPlayer.TYPE_VIDEO] = videoRenderer;
  renderers[DemoPlayer.TYPE_AUDIO] = audioRenderer;
  renderers[DemoPlayer.TYPE_METADATA] = id3Renderer;
  renderers[DemoPlayer.TYPE_TEXT] = closedCaptionRenderer;
  player.onRenderers(renderers, bandwidthMeter);
}
 
示例6
@Override
public void onSingleManifest(HlsPlaylist manifest) {
    if (canceled) {
        return;
    }

    Handler mainHandler = player.getMainHandler();
    LoadControl loadControl = new DefaultLoadControl(new DefaultAllocator(BUFFER_SEGMENT_SIZE));
    DefaultBandwidthMeter bandwidthMeter = new DefaultBandwidthMeter();

    int[] variantIndices = null;
    if (manifest instanceof HlsMasterPlaylist) {
        HlsMasterPlaylist masterPlaylist = (HlsMasterPlaylist) manifest;
        try {
            variantIndices = VideoFormatSelectorUtil.selectVideoFormatsForDefaultDisplay(
                    context, masterPlaylist.variants, null, false);
        } catch (DecoderQueryException e) {
            player.onRenderersError(e);
            return;
        }
        if (variantIndices.length == 0) {
            player.onRenderersError(new IllegalStateException("No variants selected."));
            return;
        }
    }

    DataSource dataSource = new DefaultUriDataSource(context, bandwidthMeter, userAgent);
    HlsChunkSource chunkSource = new HlsChunkSource(dataSource, url, manifest, bandwidthMeter,
            variantIndices, HlsChunkSource.ADAPTIVE_MODE_SPLICE, audioCapabilities);
    HlsSampleSource sampleSource = new HlsSampleSource(chunkSource, loadControl,
            BUFFER_SEGMENTS * BUFFER_SEGMENT_SIZE, mainHandler, player, VideoPlayer.TYPE_VIDEO);
    MediaCodecVideoTrackRenderer videoRenderer = new MediaCodecVideoTrackRenderer(sampleSource,
            MediaCodec.VIDEO_SCALING_MODE_SCALE_TO_FIT, 5000, mainHandler, player, 50);
    MediaCodecAudioTrackRenderer audioRenderer = new MediaCodecAudioTrackRenderer(sampleSource);
    MetadataTrackRenderer<Map<String, Object>> id3Renderer = new MetadataTrackRenderer<>(
            sampleSource, new Id3Parser(), player, mainHandler.getLooper());
    Eia608TrackRenderer closedCaptionRenderer = new Eia608TrackRenderer(sampleSource, player,
            mainHandler.getLooper());

    TrackRenderer[] renderers = new TrackRenderer[VideoPlayer.RENDERER_COUNT];
    renderers[VideoPlayer.TYPE_VIDEO] = videoRenderer;
    renderers[VideoPlayer.TYPE_AUDIO] = audioRenderer;
    renderers[VideoPlayer.TYPE_METADATA] = id3Renderer;
    renderers[VideoPlayer.TYPE_TEXT] = closedCaptionRenderer;
    player.onRenderers(null, null, renderers, bandwidthMeter);
}