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


Java DecoderQueryException类代码示例

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


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

示例1: handlesTrack

import com.google.android.exoplayer.MediaCodecUtil.DecoderQueryException; //导入依赖的package包/类
@Override
protected boolean handlesTrack(MediaFormat mediaFormat) throws DecoderQueryException {
    // TODO: Use MediaCodecList.findDecoderForFormat on API 23.
    String mimeType = mediaFormat.mimeType;
    return MimeTypes.isVideo(mimeType) && (MimeTypes.VIDEO_UNKNOWN.equals(mimeType)
            || MediaCodecUtil.getDecoderInfo(mimeType, false) != null);
}
 
开发者ID:quanhua92,项目名称:GLMediaPlayer,代码行数:8,代码来源:TextureVideoTrackRenderer.java

示例2: getDecoderInfo

import com.google.android.exoplayer.MediaCodecUtil.DecoderQueryException; //导入依赖的package包/类
@Override
protected DecoderInfo getDecoderInfo(String mimeType, boolean requiresSecureDecoder)
    throws DecoderQueryException {
  if (MimeTypes.isPassthroughAudio(mimeType)) {
    return new DecoderInfo(RAW_DECODER_NAME, true);
  }
  return super.getDecoderInfo(mimeType, requiresSecureDecoder);
}
 
开发者ID:XueyanLiu,项目名称:miku,代码行数:9,代码来源:MediaCodecAudioTrackRenderer.java

示例3: onError

import com.google.android.exoplayer.MediaCodecUtil.DecoderQueryException; //导入依赖的package包/类
@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();
}
 
开发者ID:asifkhan11,项目名称:ExoPlayer-Demo,代码行数:37,代码来源:PlayerActivity.java

示例4: isFormatPlayable

import com.google.android.exoplayer.MediaCodecUtil.DecoderQueryException; //导入依赖的package包/类
/**
 * Determines whether an individual format is playable, given an array of allowed container types,
 * whether HD formats should be filtered and a maximum decodable frame size in pixels.
 */
private static boolean isFormatPlayable(Format format, String[] allowedContainerMimeTypes,
    boolean filterHdFormats) throws DecoderQueryException {
  if (allowedContainerMimeTypes != null
      && !Util.contains(allowedContainerMimeTypes, format.mimeType)) {
    // Filtering format based on its container mime type.
    return false;
  }
  if (filterHdFormats && (format.width >= 1280 || format.height >= 720)) {
    // Filtering format because it's HD.
    return false;
  }
  if (format.width > 0 && format.height > 0) {
    if (Util.SDK_INT >= 21) {
      String videoMediaMimeType = MimeTypes.getVideoMediaMimeType(format.codecs);
      if (MimeTypes.VIDEO_UNKNOWN.equals(videoMediaMimeType)) {
        // Assume the video is H.264.
        videoMediaMimeType = MimeTypes.VIDEO_H264;
      }
      if (format.frameRate > 0) {
        return MediaCodecUtil.isSizeAndRateSupportedV21(videoMediaMimeType, false, format.width,
            format.height, format.frameRate);
      } else {
        return MediaCodecUtil.isSizeSupportedV21(videoMediaMimeType, false, format.width,
            format.height);
      }
    }
    // Assume the video is H.264.
    if (format.width * format.height > MediaCodecUtil.maxH264DecodableFrameSize()) {
      // Filtering format because it exceeds the maximum decodable frame size.
      return false;
    }
  }
  return true;
}
 
开发者ID:asifkhan11,项目名称:ExoPlayer-Demo,代码行数:39,代码来源:VideoFormatSelectorUtil.java

示例5: handlesTrack

import com.google.android.exoplayer.MediaCodecUtil.DecoderQueryException; //导入依赖的package包/类
@Override
protected boolean handlesTrack(MediaCodecSelector mediaCodecSelector, MediaFormat mediaFormat)
    throws DecoderQueryException {
  String mimeType = mediaFormat.mimeType;
  return MimeTypes.isVideo(mimeType) && (MimeTypes.VIDEO_UNKNOWN.equals(mimeType)
      || mediaCodecSelector.getDecoderInfo(mimeType, false) != null);
}
 
开发者ID:asifkhan11,项目名称:ExoPlayer-Demo,代码行数:8,代码来源:MediaCodecVideoTrackRenderer.java

示例6: handlesTrack

import com.google.android.exoplayer.MediaCodecUtil.DecoderQueryException; //导入依赖的package包/类
@Override
protected boolean handlesTrack(MediaCodecSelector mediaCodecSelector, MediaFormat mediaFormat)
    throws DecoderQueryException {
  String mimeType = mediaFormat.mimeType;
  return MimeTypes.isAudio(mimeType) && (MimeTypes.AUDIO_UNKNOWN.equals(mimeType)
      || (allowPassthrough(mimeType) && mediaCodecSelector.getPassthroughDecoderInfo() != null)
      || mediaCodecSelector.getDecoderInfo(mimeType, false) != null);
}
 
开发者ID:asifkhan11,项目名称:ExoPlayer-Demo,代码行数:9,代码来源:MediaCodecAudioTrackRenderer.java

示例7: getDecoderInfo

import com.google.android.exoplayer.MediaCodecUtil.DecoderQueryException; //导入依赖的package包/类
@Override
protected DecoderInfo getDecoderInfo(MediaCodecSelector mediaCodecSelector, String mimeType,
    boolean requiresSecureDecoder) throws DecoderQueryException {
  if (allowPassthrough(mimeType)) {
    DecoderInfo passthroughDecoderInfo = mediaCodecSelector.getPassthroughDecoderInfo();
    if (passthroughDecoderInfo != null) {
      passthroughEnabled = true;
      return passthroughDecoderInfo;
    }
  }
  passthroughEnabled = false;
  return super.getDecoderInfo(mediaCodecSelector, mimeType, requiresSecureDecoder);
}
 
开发者ID:asifkhan11,项目名称:ExoPlayer-Demo,代码行数:14,代码来源:MediaCodecAudioTrackRenderer.java

示例8: onError

import com.google.android.exoplayer.MediaCodecUtil.DecoderQueryException; //导入依赖的package包/类
@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();
}
 
开发者ID:konifar,项目名称:droidkaigi2016,代码行数:36,代码来源:VideoPlayerActivity.java

示例9: onSingleManifest

import com.google.android.exoplayer.MediaCodecUtil.DecoderQueryException; //导入依赖的package包/类
@Override
public void onSingleManifest(HlsPlaylist manifest) {
  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) {
      callback.onRenderersError(e);
      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, true, mainHandler, player, DemoPlayer.TYPE_VIDEO);
  MediaCodecVideoTrackRenderer videoRenderer = new MediaCodecVideoTrackRenderer(sampleSource,
      MediaCodec.VIDEO_SCALING_MODE_SCALE_TO_FIT, 5000, mainHandler, player, 50);
  MediaCodecAudioTrackRenderer audioRenderer = new MediaCodecAudioTrackRenderer(sampleSource);

  TrackRenderer[] renderers = new TrackRenderer[DemoPlayer.RENDERER_COUNT];
  renderers[DemoPlayer.TYPE_VIDEO] = videoRenderer;
  renderers[DemoPlayer.TYPE_AUDIO] = audioRenderer;
  callback.onRenderers(null, null, renderers, bandwidthMeter);
}
 
开发者ID:caspercba,项目名称:exoPlayerHLS,代码行数:34,代码来源:HlsRendererBuilder.java

示例10: onError

import com.google.android.exoplayer.MediaCodecUtil.DecoderQueryException; //导入依赖的package包/类
@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();
}
 
开发者ID:birdcopy,项目名称:Android-Birdcopy-Application,代码行数:37,代码来源:FlyingPlayerActivity.java

示例11: onSingleManifest

import com.google.android.exoplayer.MediaCodecUtil.DecoderQueryException; //导入依赖的package包/类
@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);
}
 
开发者ID:vuthanhict,项目名称:ExoPlayerController,代码行数:48,代码来源:HlsRendererBuilder.java

示例12: onSingleManifest

import com.google.android.exoplayer.MediaCodecUtil.DecoderQueryException; //导入依赖的package包/类
@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, MediaPlayer.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[MediaPlayer.RENDERER_COUNT];
  renderers[MediaPlayer.TYPE_VIDEO] = videoRenderer;
  renderers[MediaPlayer.TYPE_AUDIO] = audioRenderer;
  renderers[MediaPlayer.TYPE_METADATA] = id3Renderer;
  renderers[MediaPlayer.TYPE_TEXT] = closedCaptionRenderer;
  player.onRenderers(null, null, renderers, bandwidthMeter);
}
 
开发者ID:XueyanLiu,项目名称:miku,代码行数:46,代码来源:HlsRendererBuilder.java

示例13: handlesTrack

import com.google.android.exoplayer.MediaCodecUtil.DecoderQueryException; //导入依赖的package包/类
@Override
protected final boolean handlesTrack(MediaFormat mediaFormat) throws DecoderQueryException {
  return handlesTrack(mediaCodecSelector, mediaFormat);
}
 
开发者ID:asifkhan11,项目名称:ExoPlayer-Demo,代码行数:5,代码来源:MediaCodecTrackRenderer.java

示例14: doPrepare

import com.google.android.exoplayer.MediaCodecUtil.DecoderQueryException; //导入依赖的package包/类
@Override
protected final boolean doPrepare(long positionUs) throws ExoPlaybackException {
  boolean allSourcesPrepared = true;
  for (int i = 0; i < sources.length; i++) {
    allSourcesPrepared &= sources[i].prepare(positionUs);
  }
  if (!allSourcesPrepared) {
    return false;
  }
  // The sources are all prepared.
  int totalSourceTrackCount = 0;
  for (int i = 0; i < sources.length; i++) {
    totalSourceTrackCount += sources[i].getTrackCount();
  }
  long durationUs = 0;
  int handledTrackCount = 0;
  int[] handledSourceIndices = new int[totalSourceTrackCount];
  int[] handledTrackIndices = new int[totalSourceTrackCount];
  int sourceCount = sources.length;
  for (int sourceIndex = 0; sourceIndex < sourceCount; sourceIndex++) {
    SampleSourceReader source = sources[sourceIndex];
    int sourceTrackCount = source.getTrackCount();
    for (int trackIndex = 0; trackIndex < sourceTrackCount; trackIndex++) {
      MediaFormat format = source.getFormat(trackIndex);
      boolean handlesTrack;
      try {
        handlesTrack = handlesTrack(format);
      } catch (DecoderQueryException e) {
        throw new ExoPlaybackException(e);
      }
      if (handlesTrack) {
        handledSourceIndices[handledTrackCount] = sourceIndex;
        handledTrackIndices[handledTrackCount] = trackIndex;
        handledTrackCount++;
        if (durationUs == TrackRenderer.UNKNOWN_TIME_US) {
          // We've already encountered a track for which the duration is unknown, so the media
          // duration is unknown regardless of the duration of this track.
        } else {
          long trackDurationUs = format.durationUs;
          if (trackDurationUs == TrackRenderer.UNKNOWN_TIME_US) {
            durationUs = TrackRenderer.UNKNOWN_TIME_US;
          } else if (trackDurationUs == TrackRenderer.MATCH_LONGEST_US) {
            // Do nothing.
          } else {
            durationUs = Math.max(durationUs, trackDurationUs);
          }
        }
      }
    }
  }
  this.durationUs = durationUs;
  this.handledSourceIndices = Arrays.copyOf(handledSourceIndices, handledTrackCount);
  this.handledSourceTrackIndices = Arrays.copyOf(handledTrackIndices, handledTrackCount);
  return true;
}
 
开发者ID:asifkhan11,项目名称:ExoPlayer-Demo,代码行数:56,代码来源:SampleSourceTrackRenderer.java

示例15: getDecoderInfo

import com.google.android.exoplayer.MediaCodecUtil.DecoderQueryException; //导入依赖的package包/类
@Override
public DecoderInfo getDecoderInfo(String mimeType, boolean requiresSecureDecoder)
    throws DecoderQueryException {
  return MediaCodecUtil.getDecoderInfo(mimeType, requiresSecureDecoder);
}
 
开发者ID:asifkhan11,项目名称:ExoPlayer-Demo,代码行数:6,代码来源:MediaCodecSelector.java


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