3

I am trying to change the http headers sent when using HLS. This is what my current code looks like:

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);
}

How would I do it? I thought about using the built HttpDataSource but I couldn't pass it into HlsMediaSource or HlsMediaSource.Factory from my knowledge.

Slendi
  • 157
  • 1
  • 13

1 Answers1

2

As far as I'm aware, it should be

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

I will edit this with something to back me up if I can find it

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

You can use getDefaultRequestProperties on DataSource.Factory or HttpDataSource.Factory