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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With