【问题标题】:Exoplayer2 change HLS http headersExoplayer2 更改 HLS http 标头
【发布时间】:2021-02-04 14:50:58
【问题描述】:

我正在尝试更改使用 HLS 时发送的 http 标头。 这是我当前代码的样子:

private MediaSource buildMediaStore(String streamUrl) {
    Uri streamUri = Uri.parse(streamUrl);

    HttpDataSource.Factory dataSourceFactory = new DefaultHttpDataSourceFactory("custom_player", defaultBandwidthMeter);
    return new HlsMediaSource.Factory(dataSourceFactory).setExtractorFactory(new DefaultHlsExtractorFactory()).createMediaSource(streamUri);
}

我该怎么做?我考虑过使用构建的 HttpDataSource,但据我所知,我无法将其传递给 HlsMediaSource 或 HlsMediaSource.Factory。

【问题讨论】:

    标签: android http-live-streaming exoplayer2.x


    【解决方案1】:

    据我所知,应该是

    dataSourceFactory.getDefaultRequestProperties().set("Some Header Key", "Header Value");

    如果我能找到它,我会编辑它以支持我

    编辑: https://exoplayer.dev/doc/reference/com/google/android/exoplayer2/upstream/HttpDataSource.BaseFactory.html

    您可以在 DataSource.Factory 或 HttpDataSource.Factory 上使用 getDefaultRequestProperties

    【讨论】:

      猜你喜欢
      • 2016-11-19
      • 2014-02-17
      • 2022-12-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-05-31
      • 2015-01-02
      • 2013-10-01
      相关资源
      最近更新 更多