Java 类com.google.android.exoplayer.upstream.Allocator 实例源码

项目:AndroidTvDemo    文件:ExtractorRendererBuilder.java   
@Override
public void buildRenderers(DemoPlayer player) {
  Allocator allocator = new DefaultAllocator(BUFFER_SEGMENT_SIZE);
  Handler mainHandler = player.getMainHandler();

  // Build the video and audio renderers.
  DefaultBandwidthMeter bandwidthMeter = new DefaultBandwidthMeter(mainHandler, null);
  DataSource dataSource = new DefaultUriDataSource(context, bandwidthMeter, userAgent);
  ExtractorSampleSource sampleSource = new ExtractorSampleSource(uri, dataSource, allocator,
      BUFFER_SEGMENT_COUNT * BUFFER_SEGMENT_SIZE, mainHandler, player, 0);
  MediaCodecVideoTrackRenderer videoRenderer = new MediaCodecVideoTrackRenderer(context,
      sampleSource, MediaCodecSelector.DEFAULT, MediaCodec.VIDEO_SCALING_MODE_SCALE_TO_FIT, 5000,
      mainHandler, player, 50);
  MediaCodecAudioTrackRenderer audioRenderer = new MediaCodecAudioTrackRenderer(sampleSource,
      MediaCodecSelector.DEFAULT, null, true, mainHandler, player,
      AudioCapabilities.getCapabilities(context), AudioManager.STREAM_MUSIC);
  TrackRenderer textRenderer = new TextTrackRenderer(sampleSource, player,
      mainHandler.getLooper());

  // Invoke the callback.
  TrackRenderer[] renderers = new TrackRenderer[DemoPlayer.RENDERER_COUNT];
  renderers[DemoPlayer.TYPE_VIDEO] = videoRenderer;
  renderers[DemoPlayer.TYPE_AUDIO] = audioRenderer;
  renderers[DemoPlayer.TYPE_TEXT] = textRenderer;
  player.onRenderers(renderers, bandwidthMeter);
}
项目:ShaddockVideoPlayer    文件:ExtractorRendererBuilder.java   
@Override
public void buildRenderers(DemoPlayer player) {
  Allocator allocator = new DefaultAllocator(BUFFER_SEGMENT_SIZE);
  Handler mainHandler = player.getMainHandler();

  // Build the video and audio renderers.
  DefaultBandwidthMeter bandwidthMeter = new DefaultBandwidthMeter(mainHandler, null);
  DataSource dataSource = new DefaultUriDataSource(context, bandwidthMeter, userAgent);
  ExtractorSampleSource sampleSource = new ExtractorSampleSource(uri, dataSource, allocator,
      BUFFER_SEGMENT_COUNT * BUFFER_SEGMENT_SIZE, mainHandler, player, 0);
  MediaCodecVideoTrackRenderer videoRenderer = new MediaCodecVideoTrackRenderer(context,
      sampleSource, MediaCodecSelector.DEFAULT, MediaCodec.VIDEO_SCALING_MODE_SCALE_TO_FIT, 5000,
      mainHandler, player, 50);
  MediaCodecAudioTrackRenderer audioRenderer = new MediaCodecAudioTrackRenderer(sampleSource,
      MediaCodecSelector.DEFAULT, null, true, mainHandler, player,
      AudioCapabilities.getCapabilities(context), AudioManager.STREAM_MUSIC);
  TrackRenderer textRenderer = new TextTrackRenderer(sampleSource, player,
      mainHandler.getLooper());

  // Invoke the callback.
  TrackRenderer[] renderers = new TrackRenderer[DemoPlayer.RENDERER_COUNT];
  renderers[DemoPlayer.TYPE_VIDEO] = videoRenderer;
  renderers[DemoPlayer.TYPE_AUDIO] = audioRenderer;
  renderers[DemoPlayer.TYPE_TEXT] = textRenderer;
  player.onRenderers(renderers, bandwidthMeter);
}
项目:mimi-reader    文件:WebmRendererBuilder.java   
@Override
public void buildRenderers(ExoPlayerHelper player) {
    Allocator allocator = new DefaultAllocator(BUFFER_SEGMENT_SIZE);

    // Build the video and audio renderers.
    Extractor webmExtractor = new WebmExtractor();
    Extractor mp4Extractor = new Mp4Extractor();
    DataSource dataSource = new FileDataSource();
    ExtractorSampleSource sampleSource = new ExtractorSampleSource(uri, dataSource, allocator,
            BUFFER_SEGMENT_COUNT * BUFFER_SEGMENT_SIZE, webmExtractor, mp4Extractor);
    MediaCodecVideoTrackRenderer videoRenderer = new MediaCodecVideoTrackRenderer(context,
            sampleSource, MediaCodecSelector.DEFAULT, MediaCodec.VIDEO_SCALING_MODE_SCALE_TO_FIT, 5000, player.getMainHandler(),
            player, 50);
    MediaCodecAudioTrackRenderer audioRenderer = new MediaCodecAudioTrackRenderer(sampleSource, MediaCodecSelector.DEFAULT,
            null, true, player.getMainHandler(), player);
    TrackRenderer textRenderer = new TextTrackRenderer(sampleSource, player,
            player.getMainHandler().getLooper());

    // Invoke the callback.
    TrackRenderer[] renderers = new TrackRenderer[ExoPlayerHelper.RENDERER_COUNT];
    renderers[ExoPlayerHelper.TYPE_VIDEO] = videoRenderer;
    renderers[ExoPlayerHelper.TYPE_AUDIO] = audioRenderer;
    renderers[ExoPlayerHelper.TYPE_TEXT] = textRenderer;
    player.onRenderers(renderers, null);
}
项目:ExoPlayerController    文件:ExtractorRendererBuilder.java   
@Override
public void buildRenderers(DemoPlayer player) {
  Allocator allocator = new DefaultAllocator(BUFFER_SEGMENT_SIZE);

  // Build the video and audio renderers.
  DefaultBandwidthMeter bandwidthMeter = new DefaultBandwidthMeter(player.getMainHandler(),
      null);
  DataSource dataSource = new DefaultUriDataSource(context, bandwidthMeter, userAgent);
  ExtractorSampleSource sampleSource = new ExtractorSampleSource(uri, dataSource, allocator,
      BUFFER_SEGMENT_COUNT * BUFFER_SEGMENT_SIZE);
  MediaCodecVideoTrackRenderer videoRenderer = new MediaCodecVideoTrackRenderer(context,
      sampleSource, MediaCodec.VIDEO_SCALING_MODE_SCALE_TO_FIT, 5000, player.getMainHandler(),
      player, 50);
  MediaCodecAudioTrackRenderer audioRenderer = new MediaCodecAudioTrackRenderer(sampleSource,
      null, true, player.getMainHandler(), player, AudioCapabilities.getCapabilities(context));
  TrackRenderer textRenderer = new TextTrackRenderer(sampleSource, player,
      player.getMainHandler().getLooper());

  // Invoke the callback.
  TrackRenderer[] renderers = new TrackRenderer[DemoPlayer.RENDERER_COUNT];
  renderers[DemoPlayer.TYPE_VIDEO] = videoRenderer;
  renderers[DemoPlayer.TYPE_AUDIO] = audioRenderer;
  renderers[DemoPlayer.TYPE_TEXT] = textRenderer;
  player.onRenderers(renderers, bandwidthMeter);
}
项目:talk-android    文件:ExtractorRendererBuilder.java   
@Override
public void buildRenderers(DemoPlayer player) {
  Allocator allocator = new DefaultAllocator(BUFFER_SEGMENT_SIZE);

  // Build the video and audio renderers.
  DefaultBandwidthMeter bandwidthMeter = new DefaultBandwidthMeter(player.getMainHandler(),
      null);
  DataSource dataSource = new DefaultUriDataSource(context, bandwidthMeter, userAgent);
  ExtractorSampleSource sampleSource = new ExtractorSampleSource(uri, dataSource, allocator,
      BUFFER_SEGMENT_COUNT * BUFFER_SEGMENT_SIZE);
  MediaCodecVideoTrackRenderer videoRenderer = new MediaCodecVideoTrackRenderer(context,
      sampleSource, MediaCodec.VIDEO_SCALING_MODE_SCALE_TO_FIT, 5000, player.getMainHandler(),
      player, 50);
  MediaCodecAudioTrackRenderer audioRenderer = new MediaCodecAudioTrackRenderer(sampleSource,
      null, true, player.getMainHandler(), player, AudioCapabilities.getCapabilities(context));
  TrackRenderer textRenderer = new TextTrackRenderer(sampleSource, player,
      player.getMainHandler().getLooper());

  // Invoke the callback.
  TrackRenderer[] renderers = new TrackRenderer[DemoPlayer.RENDERER_COUNT];
  renderers[DemoPlayer.TYPE_VIDEO] = videoRenderer;
  renderers[DemoPlayer.TYPE_AUDIO] = audioRenderer;
  renderers[DemoPlayer.TYPE_TEXT] = textRenderer;
  player.onRenderers(renderers, bandwidthMeter);
}
项目:OKPlayer    文件:ExtractorRendererBuilder.java   
@Override
public void buildRenderers(DemoPlayer player) {
  Allocator allocator = new DefaultAllocator(BUFFER_SEGMENT_SIZE);
  Handler mainHandler = player.getMainHandler();

  // Build the video and audio renderers.
  DefaultBandwidthMeter bandwidthMeter = new DefaultBandwidthMeter(mainHandler, null);
  DataSource dataSource = new DefaultUriDataSource(context, bandwidthMeter, userAgent);
  ExtractorSampleSource sampleSource = new ExtractorSampleSource(uri, dataSource, allocator,
      BUFFER_SEGMENT_COUNT * BUFFER_SEGMENT_SIZE, mainHandler, player, 0);
  MediaCodecVideoTrackRenderer videoRenderer = new MediaCodecVideoTrackRenderer(context,
      sampleSource, MediaCodecSelector.DEFAULT, MediaCodec.VIDEO_SCALING_MODE_SCALE_TO_FIT, 5000,
      mainHandler, player, 50);
  MediaCodecAudioTrackRenderer audioRenderer = new MediaCodecAudioTrackRenderer(sampleSource,
      MediaCodecSelector.DEFAULT, null, true, mainHandler, player,
      AudioCapabilities.getCapabilities(context), AudioManager.STREAM_MUSIC);
  TrackRenderer textRenderer = new TextTrackRenderer(sampleSource, player,
      mainHandler.getLooper());

  // Invoke the callback.
  TrackRenderer[] renderers = new TrackRenderer[DemoPlayer.RENDERER_COUNT];
  renderers[DemoPlayer.TYPE_VIDEO] = videoRenderer;
  renderers[DemoPlayer.TYPE_AUDIO] = audioRenderer;
  renderers[DemoPlayer.TYPE_TEXT] = textRenderer;
  player.onRenderers(renderers, bandwidthMeter);
}
项目:miku    文件:ExtractorRendererBuilder.java   
@Override
public void buildRenderers(MediaPlayer player) {
  Allocator allocator = new DefaultAllocator(BUFFER_SEGMENT_SIZE);

  // Build the video and audio renderers.
  DefaultBandwidthMeter bandwidthMeter = new DefaultBandwidthMeter(player.getMainHandler(),
      null);
  DataSource dataSource = new DefaultUriDataSource(context, bandwidthMeter, userAgent);
  ExtractorSampleSource sampleSource = new ExtractorSampleSource(uri, dataSource, allocator,
      BUFFER_SEGMENT_COUNT * BUFFER_SEGMENT_SIZE);
  MediaCodecVideoTrackRenderer videoRenderer = new MediaCodecVideoTrackRenderer(sampleSource,
      null, true, MediaCodec.VIDEO_SCALING_MODE_SCALE_TO_FIT, 5000, null, player.getMainHandler(),
      player, 50);
  MediaCodecAudioTrackRenderer audioRenderer = new MediaCodecAudioTrackRenderer(sampleSource,
      null, true, player.getMainHandler(), player);
  TrackRenderer textRenderer = new TextTrackRenderer(sampleSource, player,
      player.getMainHandler().getLooper());

  // Invoke the callback.
  TrackRenderer[] renderers = new TrackRenderer[MediaPlayer.RENDERER_COUNT];
  renderers[MediaPlayer.TYPE_VIDEO] = videoRenderer;
  renderers[MediaPlayer.TYPE_AUDIO] = audioRenderer;
  renderers[MediaPlayer.TYPE_TEXT] = textRenderer;
  player.onRenderers(null, null, renderers, bandwidthMeter);
}
项目:Mediathek    文件:ExtractorRendererBuilder.java   
@Override
public void buildRenderers(Player player) {
  Allocator allocator = new DefaultAllocator(BUFFER_SEGMENT_SIZE);

  // Build the video and audio renderers.
  DefaultBandwidthMeter bandwidthMeter = new DefaultBandwidthMeter(player.getMainHandler(),
      null);
  DataSource dataSource = new DefaultUriDataSource(context, bandwidthMeter, userAgent);
  ExtractorSampleSource sampleSource = new ExtractorSampleSource(uri, dataSource, allocator,
      BUFFER_SEGMENT_COUNT * BUFFER_SEGMENT_SIZE);
  MediaCodecVideoTrackRenderer videoRenderer = new MediaCodecVideoTrackRenderer(context,
      sampleSource, MediaCodec.VIDEO_SCALING_MODE_SCALE_TO_FIT, 5000, player.getMainHandler(),
      player, 50);
  MediaCodecAudioTrackRenderer audioRenderer = new MediaCodecAudioTrackRenderer(sampleSource,
      null, true, player.getMainHandler(), player, AudioCapabilities.getCapabilities(context));
  TrackRenderer textRenderer = new TextTrackRenderer(sampleSource, player,
      player.getMainHandler().getLooper());

  // Invoke the callback.
  TrackRenderer[] renderers = new TrackRenderer[Player.RENDERER_COUNT];
  renderers[Player.TYPE_VIDEO] = videoRenderer;
  renderers[Player.TYPE_AUDIO] = audioRenderer;
  renderers[Player.TYPE_TEXT] = textRenderer;
  player.onRenderers(renderers, bandwidthMeter);
}
项目:WliveTV    文件:ExtractorRendererBuilder.java   
@Override
public void buildRenderers(DemoPlayer player) {
  Allocator allocator = new DefaultAllocator(BUFFER_SEGMENT_SIZE);

  // Build the video and audio renderers.
  DefaultBandwidthMeter bandwidthMeter = new DefaultBandwidthMeter(player.getMainHandler(),
      null);
  DataSource dataSource = new DefaultUriDataSource(context, bandwidthMeter, userAgent);
  ExtractorSampleSource sampleSource = new ExtractorSampleSource(uri, dataSource, allocator,
      BUFFER_SEGMENT_COUNT * BUFFER_SEGMENT_SIZE);
  MediaCodecVideoTrackRenderer videoRenderer = new MediaCodecVideoTrackRenderer(context,
      sampleSource, MediaCodec.VIDEO_SCALING_MODE_SCALE_TO_FIT, 5000, player.getMainHandler(),
      player, 50);
  MediaCodecAudioTrackRenderer audioRenderer = new MediaCodecAudioTrackRenderer(sampleSource,
      null, true, player.getMainHandler(), player, AudioCapabilities.getCapabilities(context));
  TrackRenderer textRenderer = new TextTrackRenderer(sampleSource, player,
      player.getMainHandler().getLooper());

  // Invoke the callback.
  TrackRenderer[] renderers = new TrackRenderer[DemoPlayer.RENDERER_COUNT];
  renderers[DemoPlayer.TYPE_VIDEO] = videoRenderer;
  renderers[DemoPlayer.TYPE_AUDIO] = audioRenderer;
  renderers[DemoPlayer.TYPE_TEXT] = textRenderer;
  player.onRenderers(renderers, bandwidthMeter);
}
项目:luxunPro    文件:RenderBuilder.java   
public void buildRenderers(EMExoPlayer player) {
    //Create the Sample Source to be used by the renderers
    Allocator allocator = new DefaultAllocator(BUFFER_SEGMENT_SIZE);
    DefaultBandwidthMeter bandwidthMeter = new DefaultBandwidthMeter(player.getMainHandler(), player);
    DataSource dataSource = createDataSource(okHttpClient, null, userAgent);

    ExtractorSampleSource sampleSource = new ExtractorSampleSource(Uri.parse(MediaUtil.getUriWithProtocol(uri)), dataSource,
           allocator, BUFFER_SEGMENT_SIZE * BUFFER_SEGMENTS_TOTAL, player.getMainHandler(), player, 0);

    //Create the Renderers
    MediaCodecVideoTrackRenderer videoRenderer = new MediaCodecVideoTrackRenderer(context, sampleSource, MediaCodecSelector.DEFAULT,
            MediaCodec.VIDEO_SCALING_MODE_SCALE_TO_FIT, MAX_JOIN_TIME, player.getMainHandler(), player, DROPPED_FRAME_NOTIFICATION_AMOUNT);
    EMMediaCodecAudioTrackRenderer audioRenderer = new EMMediaCodecAudioTrackRenderer(sampleSource, MediaCodecSelector.DEFAULT, null, true,
            player.getMainHandler(), player, AudioCapabilities.getCapabilities(context), streamType);
    TrackRenderer captionsRenderer = new TextTrackRenderer(sampleSource, player, player.getMainHandler().getLooper());


    //Create the Render list to send to the callback
    TrackRenderer[] renderers = new TrackRenderer[EMExoPlayer.RENDER_COUNT];
    renderers[EMExoPlayer.RENDER_VIDEO] = videoRenderer;
    renderers[EMExoPlayer.RENDER_AUDIO] = audioRenderer;
    renderers[EMExoPlayer.RENDER_CLOSED_CAPTION] = captionsRenderer;
    player.onRenderers(renderers, bandwidthMeter);
}
项目:exoplayer-textureview    文件:AssetsRendererBuilder.java   
@Override
protected void buildRenderers(RendererBuilderCallback callback) {
    Allocator allocator = new DefaultAllocator(bufferSegmentSize);
    DataSource dataSource = new DefaultUriDataSource(context, bandwidthMeter, userAgent);
    ExtractorSampleSource sampleSource = new ExtractorSampleSource(uri, dataSource,
            allocator, bufferSegmentSize * bufferSegmentCount);
    MediaCodecVideoTrackRenderer videoRenderer = new MediaCodecVideoTrackRenderer(context,
            sampleSource, MediaCodecSelector.DEFAULT,
            MediaCodec.VIDEO_SCALING_MODE_SCALE_TO_FIT, 5000,
            eventHandler, eventProxy, 50);
    MediaCodecAudioTrackRenderer audioRenderer = new MediaCodecAudioTrackRenderer(sampleSource,
            MediaCodecSelector.DEFAULT, null, true, eventHandler, eventProxy,
            AudioCapabilities.getCapabilities(context), AudioManager.STREAM_MUSIC);

    TrackRenderer textRenderer = new TextTrackRenderer(sampleSource, eventProxy,
            eventHandler.getLooper());

    // Invoke the callback.
    TrackRenderer[] renderers = new TrackRenderer[Player.RENDERER_COUNT];
    renderers[Player.TYPE_VIDEO] = videoRenderer;
    renderers[Player.TYPE_AUDIO] = audioRenderer;
    renderers[Player.TYPE_TEXT] = textRenderer;
    callback.onRenderers(renderers, bandwidthMeter);
}
项目:ExoPlayerWrapper    文件:ExtractorRendererBuilder.java   
@Override
public void buildRenderers(ExoPlayerWrapper player) {
    Allocator allocator = new DefaultAllocator(BUFFER_SEGMENT_SIZE);

    // Build the video and audio renderers.
    DefaultBandwidthMeter bandwidthMeter = new DefaultBandwidthMeter(player.getMainHandler(),
            null);
    DataSource dataSource = new DefaultUriDataSource(context, bandwidthMeter, userAgent);
    ExtractorSampleSource sampleSource = new ExtractorSampleSource(uri, dataSource, allocator,
            BUFFER_SEGMENT_COUNT * BUFFER_SEGMENT_SIZE);
    MediaCodecVideoTrackRenderer videoRenderer = new MediaCodecVideoTrackRenderer(context,
            sampleSource, MediaCodecSelector.DEFAULT, MediaCodec.VIDEO_SCALING_MODE_SCALE_TO_FIT, 5000,
            player.getMainHandler(), player, 50);
    MediaCodecAudioTrackRenderer audioRenderer = new MediaCodecAudioTrackRenderer(sampleSource,
            MediaCodecSelector.DEFAULT, null, true, player.getMainHandler(), player,
            AudioCapabilities.getCapabilities(context), AudioManager.STREAM_MUSIC);
    TrackRenderer textRenderer = new TextTrackRenderer(sampleSource, player,
            player.getMainHandler().getLooper());

    // Invoke the callback.
    TrackRenderer[] renderers = new TrackRenderer[ExoPlayerWrapper.RENDERER_COUNT];
    renderers[ExoPlayerWrapper.TYPE_VIDEO] = videoRenderer;
    renderers[ExoPlayerWrapper.TYPE_AUDIO] = audioRenderer;
    renderers[ExoPlayerWrapper.TYPE_TEXT] = textRenderer;
    player.onRenderers(renderers, bandwidthMeter);
}
项目:Android-Birdcopy-Application    文件:ExtractorRendererBuilder.java   
@Override
public void buildRenderers(FlyingPlayer player) {
  Allocator allocator = new DefaultAllocator(BUFFER_SEGMENT_SIZE);

  // Build the video and audio renderers.
  DefaultBandwidthMeter bandwidthMeter = new DefaultBandwidthMeter(player.getMainHandler(),
      null);
  DataSource dataSource = new DefaultUriDataSource(context, bandwidthMeter, userAgent);
  ExtractorSampleSource sampleSource = new ExtractorSampleSource(uri, dataSource, allocator,
      BUFFER_SEGMENT_COUNT * BUFFER_SEGMENT_SIZE);
  MediaCodecVideoTrackRenderer videoRenderer = new MediaCodecVideoTrackRenderer(context,
      sampleSource, MediaCodec.VIDEO_SCALING_MODE_SCALE_TO_FIT, 5000, player.getMainHandler(),
      player, 50);
  MediaCodecAudioTrackRenderer audioRenderer = new MediaCodecAudioTrackRenderer(sampleSource,
      null, true, player.getMainHandler(), player, AudioCapabilities.getCapabilities(context));
  TrackRenderer textRenderer = new TextTrackRenderer(sampleSource, player,
      player.getMainHandler().getLooper());

  // Invoke the callback.
  TrackRenderer[] renderers = new TrackRenderer[FlyingPlayer.RENDERER_COUNT];
  renderers[FlyingPlayer.TYPE_VIDEO] = videoRenderer;
  renderers[FlyingPlayer.TYPE_AUDIO] = audioRenderer;
  renderers[FlyingPlayer.TYPE_TEXT] = textRenderer;
  player.onRenderers(renderers, bandwidthMeter);
}
项目:SimpleExoPlayer    文件:ExtractorRendererBuilder.java   
@Override
public void buildRenderers(DemoPlayer player) {
    Allocator allocator = new DefaultAllocator(BUFFER_SEGMENT_SIZE);

    // Build the video and audio renderers.
    DefaultBandwidthMeter bandwidthMeter = new DefaultBandwidthMeter(player.getMainHandler(),
            null);
    DataSource dataSource = new DefaultUriDataSource(context, bandwidthMeter, userAgent);
    ExtractorSampleSource sampleSource = new ExtractorSampleSource(uri, dataSource, allocator,
            BUFFER_SEGMENT_COUNT * BUFFER_SEGMENT_SIZE);
    MediaCodecVideoTrackRenderer videoRenderer = new MediaCodecVideoTrackRenderer(context,
            sampleSource, MediaCodecSelector.DEFAULT, MediaCodec.VIDEO_SCALING_MODE_SCALE_TO_FIT, 5000,
            player.getMainHandler(), player, 50);
    MediaCodecAudioTrackRenderer audioRenderer = new MediaCodecAudioTrackRenderer(sampleSource,
            MediaCodecSelector.DEFAULT, null, true, player.getMainHandler(), player,
            AudioCapabilities.getCapabilities(context), AudioManager.STREAM_MUSIC);
    TrackRenderer textRenderer = new TextTrackRenderer(sampleSource, player,
            player.getMainHandler().getLooper());

    // Invoke the callback.
    TrackRenderer[] renderers = new TrackRenderer[DemoPlayer.RENDERER_COUNT];
    renderers[DemoPlayer.TYPE_VIDEO] = videoRenderer;
    renderers[DemoPlayer.TYPE_AUDIO] = audioRenderer;
    renderers[DemoPlayer.TYPE_TEXT] = textRenderer;
    player.onRenderers(renderers, bandwidthMeter);
}
项目:Wake2Radio    文件:WakeupActivity.java   
private void initializeMediaPlayer() {
    if (!isNetworkAvailable(getApplicationContext())) {
        playRingtone();
        bufferBar.setVisibility(View.GONE);
        radioUrlTxt.setText("No network connection available.");
        return;
    }

    exoPlayer = ExoPlayer.Factory.newInstance(1);
    Uri radioUri = Uri.parse(radioUrl);

    Allocator allocator = new DefaultAllocator(BUFFER_SEGMENT_SIZE);
    String userAgent = Util.getUserAgent(getApplicationContext(), "ExoPlayerDemo");
    DataSource dataSource = new DefaultUriDataSource(getApplicationContext(), null, userAgent);
    ExtractorSampleSource sampleSource = new ExtractorSampleSource(
            radioUri, dataSource, allocator, BUFFER_SEGMENT_SIZE * BUFFER_SEGMENT_COUNT);
    MediaCodecAudioTrackRenderer audioRenderer = new MediaCodecAudioTrackRenderer(sampleSource, MediaCodecSelector.DEFAULT);

    final AudioManager audioManager = (AudioManager) this.getSystemService(Context.AUDIO_SERVICE);
    final int maxMusicVolume = audioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
    audioManager.setStreamVolume(AudioManager.STREAM_MUSIC, maxMusicVolume, 0);
    setPlaybackVolume(audioRenderer, (float) alarmVolume / 100);

    exoPlayer.prepare(audioRenderer);
    startPlaying();
}
项目:ExoPlayer    文件:ExtractorRendererBuilder.java   
@Override
public void buildRenderers(DemoPlayer player) {
  Allocator allocator = new DefaultAllocator(BUFFER_SEGMENT_SIZE);

  // Build the video and audio renderers.
  DefaultBandwidthMeter bandwidthMeter = new DefaultBandwidthMeter(player.getMainHandler(),
      null);
  DataSource dataSource = new DefaultUriDataSource(context, bandwidthMeter, userAgent);
  ExtractorSampleSource sampleSource = new ExtractorSampleSource(uri, dataSource, allocator,
      BUFFER_SEGMENT_COUNT * BUFFER_SEGMENT_SIZE);
  MediaCodecVideoTrackRenderer videoRenderer = new MediaCodecVideoTrackRenderer(sampleSource,
      null, true, MediaCodec.VIDEO_SCALING_MODE_SCALE_TO_FIT, 5000, null, player.getMainHandler(),
      player, 50);
  MediaCodecAudioTrackRenderer audioRenderer = new MediaCodecAudioTrackRenderer(sampleSource,
      null, true, player.getMainHandler(), player);
  TrackRenderer textRenderer = new TextTrackRenderer(sampleSource, player,
      player.getMainHandler().getLooper());

  // Invoke the callback.
  TrackRenderer[] renderers = new TrackRenderer[DemoPlayer.RENDERER_COUNT];
  renderers[DemoPlayer.TYPE_VIDEO] = videoRenderer;
  renderers[DemoPlayer.TYPE_AUDIO] = audioRenderer;
  renderers[DemoPlayer.TYPE_TEXT] = textRenderer;
  player.onRenderers(null, null, renderers, bandwidthMeter);
}
项目:google-media-framework-android    文件:ExtractorRendererBuilder.java   
@Override
public void buildRenderers(ExoplayerWrapper player) {
    Allocator allocator = new DefaultAllocator(BUFFER_SEGMENT_SIZE);

    // Build the video and audio renderers.
    DefaultBandwidthMeter bandwidthMeter = new DefaultBandwidthMeter(player.getMainHandler(),
            null);
    DataSource dataSource = new DefaultUriDataSource(context, bandwidthMeter, userAgent);
    ExtractorSampleSource sampleSource = new ExtractorSampleSource(uri, dataSource, allocator,
            BUFFER_SEGMENT_COUNT * BUFFER_SEGMENT_SIZE);
    MediaCodecVideoTrackRenderer videoRenderer = new MediaCodecVideoTrackRenderer(context,
            sampleSource, MediaCodecSelector.DEFAULT, MediaCodec.VIDEO_SCALING_MODE_SCALE_TO_FIT,
            5000, player.getMainHandler(), player, 50);
    MediaCodecAudioTrackRenderer audioRenderer = new MediaCodecAudioTrackRenderer(sampleSource,
            MediaCodecSelector.DEFAULT, null, true, player.getMainHandler(), player,
            AudioCapabilities.getCapabilities(context), AudioManager.STREAM_MUSIC);
    TrackRenderer textRenderer = new TextTrackRenderer(sampleSource, player,
            player.getMainHandler().getLooper());

    // Invoke the callback.
    TrackRenderer[] renderers = new TrackRenderer[ExoplayerWrapper.RENDERER_COUNT];
    renderers[ExoplayerWrapper.TYPE_VIDEO] = videoRenderer;
    renderers[ExoplayerWrapper.TYPE_AUDIO] = audioRenderer;
    renderers[ExoplayerWrapper.TYPE_TEXT] = textRenderer;
    player.onRenderers(renderers, bandwidthMeter);
}
项目:androidtv-sample    文件:ExtractorRendererBuilder.java   
@Override
public void buildRenderers(DemoPlayer player) {
    Allocator allocator = new DefaultAllocator(BUFFER_SEGMENT_SIZE);

    // Build the video and audio renderers.
    DefaultBandwidthMeter bandwidthMeter = new DefaultBandwidthMeter(player.getMainHandler(),
            null);
    DataSource dataSource = new DefaultUriDataSource(context, bandwidthMeter, userAgent);
    ExtractorSampleSource sampleSource = new ExtractorSampleSource(uri, dataSource, allocator,
            BUFFER_SEGMENT_COUNT * BUFFER_SEGMENT_SIZE);
    MediaCodecVideoTrackRenderer videoRenderer = new MediaCodecVideoTrackRenderer(context,
            sampleSource, MediaCodecSelector.DEFAULT,
            MediaCodec.VIDEO_SCALING_MODE_SCALE_TO_FIT, 5000,
            player.getMainHandler(), player, 50);
    MediaCodecAudioTrackRenderer audioRenderer = new MediaCodecAudioTrackRenderer(sampleSource,
            MediaCodecSelector.DEFAULT, null, true, player.getMainHandler(), player,
            AudioCapabilities.getCapabilities(context), AudioManager.STREAM_MUSIC);
    TrackRenderer textRenderer = new TextTrackRenderer(sampleSource, player,
            player.getMainHandler().getLooper());

    // Invoke the callback.
    TrackRenderer[] renderers = new TrackRenderer[DemoPlayer.RENDERER_COUNT];
    renderers[DemoPlayer.TYPE_VIDEO] = videoRenderer;
    renderers[DemoPlayer.TYPE_AUDIO] = audioRenderer;
    renderers[DemoPlayer.TYPE_TEXT] = textRenderer;
    player.onRenderers(renderers, bandwidthMeter);
}
项目:androidtv-sample    文件:ExtractorRendererBuilder.java   
@Override
public void buildRenderers(VideoPlayer player) {
    Allocator allocator = new DefaultAllocator(BUFFER_SEGMENT_SIZE);

    // Build the video and audio renderers.
    DefaultBandwidthMeter bandwidthMeter = new DefaultBandwidthMeter(player.getMainHandler(),
            null);
    DataSource dataSource = new DefaultUriDataSource(context, bandwidthMeter, userAgent);
    ExtractorSampleSource sampleSource = new ExtractorSampleSource(uri, dataSource, allocator,
            BUFFER_SEGMENT_COUNT * BUFFER_SEGMENT_SIZE);
    MediaCodecVideoTrackRenderer videoRenderer = new MediaCodecVideoTrackRenderer(context,
            sampleSource, MediaCodecSelector.DEFAULT,
            MediaCodec.VIDEO_SCALING_MODE_SCALE_TO_FIT, 5000,
            player.getMainHandler(), player, 50);
    MediaCodecAudioTrackRenderer audioRenderer = new MediaCodecAudioTrackRenderer(sampleSource,
            MediaCodecSelector.DEFAULT, null, true, player.getMainHandler(), player,
            AudioCapabilities.getCapabilities(context), AudioManager.STREAM_MUSIC);
    TrackRenderer textRenderer = new TextTrackRenderer(sampleSource, player,
            player.getMainHandler().getLooper());

    // Invoke the callback.
    TrackRenderer[] renderers = new TrackRenderer[VideoPlayer.RENDERER_COUNT];
    renderers[VideoPlayer.TYPE_VIDEO] = videoRenderer;
    renderers[VideoPlayer.TYPE_AUDIO] = audioRenderer;
    renderers[VideoPlayer.TYPE_TEXT] = textRenderer;
    player.onRenderers(renderers, bandwidthMeter);
}
项目:chilly    文件:ExtractorRendererBuilder.java   
@Override
public void buildRenderers(VideoPlayer player) {
    Allocator allocator = new DefaultAllocator(BUFFER_SEGMENT_SIZE);

    // Build the video and audio renderers.
    DefaultBandwidthMeter bandwidthMeter = new DefaultBandwidthMeter(player.getMainHandler(),
            null);
    DataSource dataSource = new DefaultUriDataSource(context, bandwidthMeter, userAgent);
    ExtractorSampleSource sampleSource = new ExtractorSampleSource(uri, dataSource, allocator,
            BUFFER_SEGMENT_COUNT * BUFFER_SEGMENT_SIZE);
    MediaCodecVideoTrackRenderer videoRenderer = new MediaCodecVideoTrackRenderer(context,
            sampleSource, MediaCodecSelector.DEFAULT,
            MediaCodec.VIDEO_SCALING_MODE_SCALE_TO_FIT, 5000,
            player.getMainHandler(), player, 50);
    MediaCodecAudioTrackRenderer audioRenderer = new MediaCodecAudioTrackRenderer(sampleSource,
            MediaCodecSelector.DEFAULT, null, true, player.getMainHandler(), player,
            AudioCapabilities.getCapabilities(context), AudioManager.STREAM_MUSIC);
    TrackRenderer textRenderer = new TextTrackRenderer(sampleSource, player,
            player.getMainHandler().getLooper());

    // Invoke the callback.
    TrackRenderer[] renderers = new TrackRenderer[VideoPlayer.RENDERER_COUNT];
    renderers[VideoPlayer.TYPE_VIDEO] = videoRenderer;
    renderers[VideoPlayer.TYPE_AUDIO] = audioRenderer;
    renderers[VideoPlayer.TYPE_TEXT] = textRenderer;
    player.onRenderers(renderers, bandwidthMeter);
}
项目:android-tv-news    文件:ExtractorRendererBuilder.java   
@Override
public void buildRenderers(VideoPlayer player) {
    Allocator allocator = new DefaultAllocator(BUFFER_SEGMENT_SIZE);

    // Build the video and audio renderers.
    DefaultBandwidthMeter bandwidthMeter = new DefaultBandwidthMeter(player.getMainHandler(),
            null);
    DataSource dataSource = new DefaultUriDataSource(context, bandwidthMeter, userAgent);
    ExtractorSampleSource sampleSource = new ExtractorSampleSource(uri, dataSource, allocator,
            BUFFER_SEGMENT_COUNT * BUFFER_SEGMENT_SIZE);
    MediaCodecVideoTrackRenderer videoRenderer = new MediaCodecVideoTrackRenderer(context,
            sampleSource, MediaCodecSelector.DEFAULT,
            MediaCodec.VIDEO_SCALING_MODE_SCALE_TO_FIT, 5000,
            player.getMainHandler(), player, 50);
    MediaCodecAudioTrackRenderer audioRenderer = new MediaCodecAudioTrackRenderer(sampleSource,
            MediaCodecSelector.DEFAULT, null, true, player.getMainHandler(), player,
            AudioCapabilities.getCapabilities(context), AudioManager.STREAM_MUSIC);
    TrackRenderer textRenderer = new TextTrackRenderer(sampleSource, player,
            player.getMainHandler().getLooper());

    // Invoke the callback.
    TrackRenderer[] renderers = new TrackRenderer[VideoPlayer.RENDERER_COUNT];
    renderers[VideoPlayer.TYPE_VIDEO] = videoRenderer;
    renderers[VideoPlayer.TYPE_AUDIO] = audioRenderer;
    renderers[VideoPlayer.TYPE_TEXT] = textRenderer;
    player.onRenderers(renderers, bandwidthMeter);
}
项目:FriendsCameraSDK-android    文件:ExtractorRendererBuilder.java   
@Override
public void buildRenderers(DemoPlayer player) {
  Allocator allocator = new DefaultAllocator(BUFFER_SEGMENT_SIZE);
  Handler mainHandler = player.getMainHandler();

  // Build the video and audio renderers.
  DefaultBandwidthMeter bandwidthMeter = new DefaultBandwidthMeter(mainHandler, null);
  dataSource  = new CameraDataSource( bandwidthMeter);
  try {
    dataSource.open(new DataSpec(uri));
  } catch (IOException e) {
    e.printStackTrace();
  }
  ExtractorSampleSource sampleSource = new ExtractorSampleSource(uri, dataSource, allocator,
      BUFFER_SEGMENT_COUNT * BUFFER_SEGMENT_SIZE, mainHandler, player, 0);
  MediaCodecVideoTrackRenderer videoRenderer = new MediaCodecVideoTrackRenderer(context,
      sampleSource, MediaCodecSelector.DEFAULT, MediaCodec.VIDEO_SCALING_MODE_SCALE_TO_FIT, 5000,
      mainHandler, player, 50);
  MediaCodecAudioTrackRenderer audioRenderer = new MediaCodecAudioTrackRenderer(sampleSource,
      MediaCodecSelector.DEFAULT, null, true, mainHandler, player,
      AudioCapabilities.getCapabilities(context), AudioManager.STREAM_MUSIC);
  TrackRenderer textRenderer = new TextTrackRenderer(sampleSource, player,
      mainHandler.getLooper());

  // Invoke the callback.
  TrackRenderer[] renderers = new TrackRenderer[DemoPlayer.RENDERER_COUNT];
  renderers[DemoPlayer.TYPE_VIDEO] = videoRenderer;
  renderers[DemoPlayer.TYPE_AUDIO] = audioRenderer;
  renderers[DemoPlayer.TYPE_TEXT] = textRenderer;
  player.onRenderers(renderers, bandwidthMeter);
}
项目:radiocom-android    文件:StreamingService.java   
@Override
public void onStart(Intent paramIntent, int paramInt) {

    //stop the streaming
    Intent i = new Intent(StreamingService.this, PodcastingService.class);
    stopService(i);

    if (paramIntent != null) {
        this.audio = paramIntent.getStringExtra("audio");
        this.title = paramIntent.getStringExtra("title");
        this.text = paramIntent.getStringExtra("text");
        this.logo_url = paramIntent.getStringExtra("logo_url");
        this.logo = paramIntent.getByteArrayExtra("logo");
        this.mNM = ((NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE));

        try {
            // String with the url of the radio you want to play
            Uri radioUri = Uri.parse(audio);
            // Settings for exoPlayer
            Allocator allocator = new DefaultAllocator(BUFFER_SEGMENT_SIZE);
            String userAgent = Util.getUserAgent(this, "ComRadioPlayer");
            DataSource dataSource = new DefaultUriDataSource(this, null, userAgent);
            ExtractorSampleSource sampleSource = new ExtractorSampleSource(radioUri, dataSource, allocator, BUFFER_SEGMENT_SIZE * BUFFER_SEGMENT_COUNT);
            audioRenderer = new MediaCodecAudioTrackRenderer(sampleSource);
            // Prepare ExoPlayer
            exoPlayer.prepare(audioRenderer);
            exoPlayer.setPlayWhenReady(true);

            showNotification(text, title);
        } catch (Exception e) {
            Log.d("Streaming", "onStart", e);
        }
    }

}
项目:android_packages_apps_tv    文件:ExoPlayerSampleExtractor.java   
public ExoPlayerSampleExtractor(Uri uri, DataSource source, BufferManager bufferManager,
        PlaybackBufferListener bufferListener, boolean isRecording) {
    // It'll be used as a timeshift file chunk name's prefix.
    mId = System.currentTimeMillis();
    Allocator allocator = new DefaultAllocator(BUFFER_SEGMENT_SIZE_IN_BYTES);

    EventListener eventListener = new EventListener() {

        @Override
        public void onLoadError(int sourceId, IOException e) {
            mError = e;
        }
    };

    mSourceReaderThread = new HandlerThread("SourceReaderThread");
    mSourceReaderWorker = new SourceReaderWorker(new ExtractorSampleSource(uri, source,
            allocator, BUFFER_SEGMENT_COUNT * BUFFER_SEGMENT_SIZE_IN_BYTES,
            // Do not create a handler if we not on a looper. e.g. test.
            Looper.myLooper() != null ? new Handler() : null,
            eventListener, 0));
    if (isRecording) {
        mSampleBuffer = new RecordingSampleBuffer(bufferManager, bufferListener, false,
                RecordingSampleBuffer.BUFFER_REASON_RECORDING);
    } else {
        if (bufferManager == null || bufferManager.isDisabled()) {
            mSampleBuffer = new SimpleSampleBuffer(bufferListener);
        } else {
            mSampleBuffer = new RecordingSampleBuffer(bufferManager, bufferListener, true,
                    RecordingSampleBuffer.BUFFER_REASON_LIVE_PLAYBACK);
        }
    }
}
项目:GLMediaPlayer    文件:CustomExoPlayer.java   
private void preparePlayer(boolean playWhenReady) {
        Uri uri = Uri.parse(dataPath);
        Allocator allocator = new DefaultAllocator(BUFFER_SEGMENT_SIZE);
        // Build the video and audio renderers.
        DefaultBandwidthMeter bandwidthMeter = new DefaultBandwidthMeter(getMainHandler(), null);
        DataSource dataSource = new DefaultUriDataSource(context, bandwidthMeter, userAgent);
        ExtractorSampleSource sampleSource = new ExtractorSampleSource(uri, dataSource, allocator,
                BUFFER_SEGMENT_COUNT * BUFFER_SEGMENT_SIZE, null);


        TextureVideoTrackRenderer videoRenderer = new TextureVideoTrackRenderer(context, sampleSource, MediaCodec.VIDEO_SCALING_MODE_SCALE_TO_FIT, 5000
                , null, true, getMainHandler(), this, 50);

        MediaCodecAudioTrackRenderer audioRenderer = new MediaCodecAudioTrackRenderer(sampleSource,
                null, true, getMainHandler(), this, AudioCapabilities.getCapabilities(context));

        // Invoke the callback.
        TrackRenderer[] renderers = new TrackRenderer[RENDERER_COUNT];
        renderers[TYPE_VIDEO] = videoRenderer;
        renderers[TYPE_AUDIO] = audioRenderer;

        player.sendMessage(
                videoRenderer, MediaCodecVideoTrackRenderer.MSG_SET_SURFACE, surface);
        Log.e(TAG, "after send Message");
//        onRenderers(renderers, bandwidthMeter);
        player.prepare(renderers);
        player.setPlayWhenReady(playWhenReady);
    }
项目:miku    文件:RollingSampleBuffer.java   
/**
 * @param allocator An {@link Allocator} from which allocations for sample data can be obtained.
 */
public RollingSampleBuffer(Allocator allocator) {
  this.allocator = allocator;
  allocationLength = allocator.getIndividualAllocationLength();
  infoQueue = new InfoQueue();
  dataQueue = new LinkedBlockingDeque<>();
  extrasHolder = new SampleExtrasHolder();
  scratch = new ParsableByteArray(INITIAL_SCRATCH_SIZE);
  lastAllocationOffset = allocationLength;
}
项目:miku    文件:ExtractorSampleSource.java   
public ExtractingLoadable(Uri uri, DataSource dataSource, ExtractorHolder extractorHolder,
    Allocator allocator, int requestedBufferSize, long position) {
  this.uri = Assertions.checkNotNull(uri);
  this.dataSource = Assertions.checkNotNull(dataSource);
  this.extractorHolder = Assertions.checkNotNull(extractorHolder);
  this.allocator = Assertions.checkNotNull(allocator);
  this.requestedBufferSize = requestedBufferSize;
  positionHolder = new PositionHolder();
  positionHolder.position = position;
  pendingExtractorSeek = true;
}
项目:miku    文件:DefaultTrackOutput.java   
/**
 * @param allocator An {@link Allocator} from which allocations for sample data can be obtained.
 */
public DefaultTrackOutput(Allocator allocator) {
  rollingBuffer = new RollingSampleBuffer(allocator);
  sampleInfoHolder = new SampleHolder(SampleHolder.BUFFER_REPLACEMENT_MODE_DISABLED);
  needKeyframe = true;
  lastReadTimeUs = Long.MIN_VALUE;
  spliceOutTimeUs = Long.MIN_VALUE;
  largestParsedTimestampUs = Long.MIN_VALUE;
}
项目:android-oss    文件:KSRendererBuilder.java   
@Override
public void buildRenderers(final @NonNull KSVideoPlayer player) {
  final Allocator allocator = new DefaultAllocator(BUFFER_SEGMENT_SIZE);
  final DataSource dataSource = new DefaultUriDataSource(this.context, null, this.videoLink, true);
  final ExtractorSampleSource sampleSource = new ExtractorSampleSource(Uri.parse(this.videoLink), dataSource,
    allocator, BUFFER_SEGMENT_COUNT * BUFFER_SEGMENT_SIZE);

  final MediaCodecVideoTrackRenderer videoRenderer = new MediaCodecVideoTrackRenderer(this.context, sampleSource,
    MediaCodecSelector.DEFAULT, MediaCodec.VIDEO_SCALING_MODE_SCALE_TO_FIT);
  final MediaCodecAudioTrackRenderer audioRenderer = new MediaCodecAudioTrackRenderer(sampleSource, MediaCodecSelector.DEFAULT);

  player.prepareRenderers(videoRenderer, audioRenderer);
}
项目:ExoPlayer-Demo    文件:RollingSampleBuffer.java   
/**
 * @param allocator An {@link Allocator} from which allocations for sample data can be obtained.
 */
public RollingSampleBuffer(Allocator allocator) {
  this.allocator = allocator;
  allocationLength = allocator.getIndividualAllocationLength();
  infoQueue = new InfoQueue();
  dataQueue = new LinkedBlockingDeque<>();
  extrasHolder = new SampleExtrasHolder();
  scratch = new ParsableByteArray(INITIAL_SCRATCH_SIZE);
  lastAllocationOffset = allocationLength;
}
项目:ExoPlayer-Demo    文件:ExtractorSampleSource.java   
public ExtractingLoadable(Uri uri, DataSource dataSource, ExtractorHolder extractorHolder,
    Allocator allocator, int requestedBufferSize, long position) {
  this.uri = Assertions.checkNotNull(uri);
  this.dataSource = Assertions.checkNotNull(dataSource);
  this.extractorHolder = Assertions.checkNotNull(extractorHolder);
  this.allocator = Assertions.checkNotNull(allocator);
  this.requestedBufferSize = requestedBufferSize;
  positionHolder = new PositionHolder();
  positionHolder.position = position;
  pendingExtractorSeek = true;
}
项目:ExoPlayer-Demo    文件:DefaultTrackOutput.java   
/**
 * @param allocator An {@link Allocator} from which allocations for sample data can be obtained.
 */
public DefaultTrackOutput(Allocator allocator) {
  rollingBuffer = new RollingSampleBuffer(allocator);
  sampleInfoHolder = new SampleHolder(SampleHolder.BUFFER_REPLACEMENT_MODE_DISABLED);
  needKeyframe = true;
  lastReadTimeUs = Long.MIN_VALUE;
  spliceOutTimeUs = Long.MIN_VALUE;
  largestParsedTimestampUs = Long.MIN_VALUE;
}
项目:meiShi    文件:VideoView.java   
private SampleSource createSource() {
    Allocator allocator = new DefaultAllocator(BUFFER_SEGMENT_SIZE);
    DefaultBandwidthMeter bandwidthMeter = new DefaultBandwidthMeter(handler,
            null);
    DataSource dataSource = new DefaultUriDataSource(getContext(), bandwidthMeter, "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.76 Mobile Safari/537.36");
    ExtractorSampleSource sampleSource = new ExtractorSampleSource(mUri, dataSource, allocator,
            BUFFER_SEGMENT_COUNT * BUFFER_SEGMENT_SIZE);
    return sampleSource;
}
项目:OkPlayer    文件:ExtractorRendererBuilder.java   
@Override
    public void buildRenderers(OkPlayer player) {

        Allocator allocator = new DefaultAllocator(BUFFER_SEGMENT_SIZE);
        DefaultBandwidthMeter bandwidthMeter = new DefaultBandwidthMeter(player.getMainHandler(),
                player);

        DataSource dataSource = new DefaultUriDataSource(context, bandwidthMeter, userAgent);
        ExtractorSampleSource sampleSource = new ExtractorSampleSource(uri, dataSource, allocator,
                BUFFER_SEGMENT_COUNT * BUFFER_SEGMENT_SIZE);

//        Uri uri = Uri.parse(MediaUtil.getUriWithProtocol(this.uri.toString()));
//        ExtractorSampleSource sampleSource = new ExtractorSampleSource(uri, dataSource, allocator,
//                BUFFER_SEGMENT_COUNT * BUFFER_SEGMENT_SIZE, new Mp4Extractor());

        MediaCodecVideoTrackRenderer videoRenderer = new MediaCodecVideoTrackRenderer(context,
                sampleSource, MediaCodec.VIDEO_SCALING_MODE_SCALE_TO_FIT, 5000, player.getMainHandler(),
                player, 50);
        MediaCodecAudioTrackRenderer audioRenderer = new MediaCodecAudioTrackRenderer(sampleSource,
                null, true, player.getMainHandler(), player, AudioCapabilities.getCapabilities(context));
//        TrackRenderer textRenderer = new TextTrackRenderer(sampleSource, player,
//                player.getMainHandler().getLooper());

        // Invoke the callback.
        TrackRenderer[] renderers = new TrackRenderer[OkPlayer.RENDERER_COUNT];
        renderers[OkPlayer.TYPE_VIDEO] = videoRenderer;
        renderers[OkPlayer.TYPE_AUDIO] = audioRenderer;
//        renderers[OkPlayer.TYPE_TEXT] = textRenderer;
        player.onRenderers(renderers, bandwidthMeter);
    }
项目:ExoPlayer    文件:RollingSampleBuffer.java   
/**
 * @param allocator An {@link Allocator} from which allocations for sample data can be obtained.
 */
public RollingSampleBuffer(Allocator allocator) {
  this.allocator = allocator;
  allocationLength = allocator.getIndividualAllocationLength();
  infoQueue = new InfoQueue();
  dataQueue = new LinkedBlockingDeque<>();
  extrasHolder = new SampleExtrasHolder();
  scratch = new ParsableByteArray(INITIAL_SCRATCH_SIZE);
  lastAllocationOffset = allocationLength;
}
项目:ExoPlayer    文件:ExtractorSampleSource.java   
public ExtractingLoadable(Uri uri, DataSource dataSource, ExtractorHolder extractorHolder,
    Allocator allocator, int requestedBufferSize, long position) {
  this.uri = Assertions.checkNotNull(uri);
  this.dataSource = Assertions.checkNotNull(dataSource);
  this.extractorHolder = Assertions.checkNotNull(extractorHolder);
  this.allocator = Assertions.checkNotNull(allocator);
  this.requestedBufferSize = requestedBufferSize;
  positionHolder = new PositionHolder();
  positionHolder.position = position;
  pendingExtractorSeek = true;
}
项目:ExoPlayer    文件:DefaultTrackOutput.java   
/**
 * @param allocator An {@link Allocator} from which allocations for sample data can be obtained.
 */
public DefaultTrackOutput(Allocator allocator) {
  rollingBuffer = new RollingSampleBuffer(allocator);
  sampleInfoHolder = new SampleHolder(SampleHolder.BUFFER_REPLACEMENT_MODE_DISABLED);
  needKeyframe = true;
  lastReadTimeUs = Long.MIN_VALUE;
  spliceOutTimeUs = Long.MIN_VALUE;
  largestParsedTimestampUs = Long.MIN_VALUE;
}
项目:androidtv-sample-inputs    文件:ExtractorRendererBuilder.java   
@Override
public void buildRenderers(DemoPlayer player) {
    Allocator allocator = new DefaultAllocator(BUFFER_SEGMENT_SIZE);

    // Build the video and audio renderers.
    DefaultBandwidthMeter bandwidthMeter = new DefaultBandwidthMeter(player.getMainHandler(),
            null);
    DataSource dataSource = new DefaultUriDataSource(context, bandwidthMeter, userAgent);
    ExtractorSampleSource sampleSource = new ExtractorSampleSource(uri, dataSource, allocator,
            BUFFER_SEGMENT_COUNT * BUFFER_SEGMENT_SIZE);
    MediaCodecVideoTrackRenderer videoRenderer = new MediaCodecVideoTrackRenderer(context,
            sampleSource, MediaCodecSelector.DEFAULT,
            MediaCodec.VIDEO_SCALING_MODE_SCALE_TO_FIT, 5000,
            player.getMainHandler(), player, 50);
    MediaCodecAudioTrackRenderer audioRenderer = new MediaCodecAudioTrackRenderer(sampleSource,
            MediaCodecSelector.DEFAULT, null, true, player.getMainHandler(), player,
            AudioCapabilities.getCapabilities(context), AudioManager.STREAM_MUSIC);
    TrackRenderer textRenderer = new TextTrackRenderer(sampleSource, player,
            player.getMainHandler().getLooper());

    // Invoke the callback.
    TrackRenderer[] renderers = new TrackRenderer[DemoPlayer.RENDERER_COUNT];
    renderers[DemoPlayer.TYPE_VIDEO] = videoRenderer;
    renderers[DemoPlayer.TYPE_AUDIO] = audioRenderer;
    renderers[DemoPlayer.TYPE_TEXT] = textRenderer;
    player.onRenderers(renderers, bandwidthMeter);
}
项目:ANE-AACPlayer    文件:LoadFunction.java   
@Override
public FREObject call(FREContext context, FREObject[] args) {
    super.call(context, args);

    this._playerContext = (AirAACPlayerExtensionContext) context;

    this._url = getStringFromFREObject(args[0]);

    if(this._url.contains("http://") || this._url.contains("https://")) {
        FileLoader fileLoader = new FileLoader(this);
        this._playerContext.set_fileLoader(fileLoader);
        fileLoader.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, this._url);
    }
    else {

        // local file
        try {

            this._playerContext.set_player(ExoPlayer.Factory.newInstance(1, 500, 2500));
            this._playerContext.get_player().addListener(this._playerContext);

            Allocator allocator = new DefaultAllocator(AirAACPlayerExtensionContext.BUFFER_SEGMENT_SIZE);

            DataSource dataSource = new AssetDataSource(context.getActivity().getApplicationContext());
            ExtractorSampleSource sampleSource = new ExtractorSampleSource(Uri.parse(this._url), dataSource, allocator,
                    AirAACPlayerExtensionContext.BUFFER_SEGMENT_COUNT * AirAACPlayerExtensionContext.BUFFER_SEGMENT_SIZE);
            MediaCodecAudioTrackRenderer renderer = new MediaCodecAudioTrackRenderer(sampleSource, MediaCodecSelector.DEFAULT);
            this._playerContext.setup(renderer);
            this._playerContext.dispatchStatusEventAsync(AirAACPlayerEvent_AAC_PLAYER_LOADED, "");

        }
        catch (Exception e) {
            this._playerContext.dispatchStatusEventAsync(AirAACPlayerEvent_AAC_PLAYER_ERROR, "" + e.getLocalizedMessage());
        }
    }

    return null;

}
项目:ANE-AACPlayer    文件:LoadFunction.java   
@Override
public void onLoaded(byte[] bytes) {

    // prepare
    if (this._playerContext.get_player() == null && bytes != null) {

        this._playerContext.set_player(ExoPlayer.Factory.newInstance(1, 500, 2500));
        this._playerContext.get_player().addListener(this._playerContext);

        Allocator allocator = new DefaultAllocator(AirAACPlayerExtensionContext.BUFFER_SEGMENT_SIZE);

        DataSource dataSource = new ByteArrayDataSource(bytes);
        ExtractorSampleSource sampleSource = new ExtractorSampleSource(Uri.parse(this._url), dataSource, allocator,
                AirAACPlayerExtensionContext.BUFFER_SEGMENT_COUNT * AirAACPlayerExtensionContext.BUFFER_SEGMENT_SIZE);
        MediaCodecAudioTrackRenderer renderer = new MediaCodecAudioTrackRenderer(sampleSource, MediaCodecSelector.DEFAULT);
        this._playerContext.setup(renderer);
        this._playerContext.dispatchStatusEventAsync(AirAACPlayerEvent_AAC_PLAYER_LOADED, "");
    }
    else if (bytes == null) {
        if(!_playerContext.is_disposed())
            this._playerContext.dispatchStatusEventAsync(AirAACPlayerEvent_AAC_PLAYER_ERROR, "ExoPlayer error bytes are null");
    }
    else if (bytes.length < 1) {
        if(!_playerContext.is_disposed())
            this._playerContext.dispatchStatusEventAsync(AirAACPlayerEvent_AAC_PLAYER_ERROR, "Downloaded file had 0 bytes");
    }
}