尝试使用ExoPlayer - 许多未知数

时间:2015-01-20 11:33:16

标签: android exoplayer

在互联网上没有提到用户代理究竟是什么,我将传递什么作为其价值以及它用于什么。没有文档,没有。 另外,我如何获得" videoRepresentations"它是什么?

enter image description here

    // Build the video renderer.
    DataSource videoDataSource = new HttpDataSource(userAgent, HttpDataSource.REJECT_PAYWALL_TYPES, bandwidthMeter);
    ChunkSource videoChunkSource = new DashChunkSource(videoDataSource, new AdaptiveEvaluator(bandwidthMeter), videoRepresentations);
    ChunkSampleSource videoSampleSource = new ChunkSampleSource(videoChunkSource, loadControl, VIDEO_BUFFER_SEGMENTS * BUFFER_SEGMENT_SIZE, true);
    MediaCodecVideoTrackRenderer videoRenderer = new MediaCodecVideoTrackRenderer(videoSampleSource, null, true, MediaCodec.VIDEO_SCALING_MODE_SCALE_TO_FIT, 0, mainHandler, playerActivity, 50);

    // Build the audio renderer.
    DataSource audioDataSource = new HttpDataSource(userAgent, HttpDataSource.REJECT_PAYWALL_TYPES, bandwidthMeter);
    ChunkSource audioChunkSource = new DashChunkSource(audioDataSource, new FormatEvaluator.FixedEvaluator(), audioRepresentation);
    SampleSource audioSampleSource = new ChunkSampleSource(audioChunkSource, loadControl, AUDIO_BUFFER_SEGMENTS * BUFFER_SEGMENT_SIZE, true);
    MediaCodecAudioTrackRenderer audioRenderer = new MediaCodecAudioTrackRenderer(audioSampleSource, null, true);

文档非常不足 http://developer.android.com/guide/topics/media/exoplayer.html

1 个答案:

答案 0 :(得分:1)

<强>的userAgent

  private RendererBuilder getRendererBuilder() {
    String userAgent = DemoUtil.getUserAgent(this);
    switch (contentType) {
      case DemoUtil.TYPE_SS:
        return new SmoothStreamingRendererBuilder(userAgent, contentUri.toString(), contentId,
            new SmoothStreamingTestMediaDrmCallback(), debugTextView);
      case DemoUtil.TYPE_DASH:
        return new DashRendererBuilder(userAgent, contentUri.toString(), contentId,
            new WidevineTestMediaDrmCallback(contentId), debugTextView);
      default:
        return new DefaultRendererBuilder(this, contentUri, debugTextView);
    }
  }

上面的代码来自下面的链接,您只需下载并使用它就可以使用整个代码。

https://raw.githubusercontent.com/google/ExoPlayer/master/demo/src/main/java/com/google/android/exoplayer/demo/full/FullPlayerActivity.java

https://raw.githubusercontent.com/google/ExoPlayer/master/demo/src/main/java/com/google/android/exoplayer/demo/simple/SimplePlayerActivity.java