I use ExoPlayer for playback of videos from url in my app and need to set an authorization header for each video. DefaultHttpDataSource can be used for that. For example,
DefaultHttpDataSource source = new DefaultHttpDataSource(Util.getUserAgent(mContext, "appAgent"), null);
source.setRequestProperty("Authorization", authToken);
MediaSource is needed to prepare the player. The question is how to create a MediaSource based on DefaultHttpDataSource? Both of the constructors of ExtractorMediaSource require DataSource.Factory, not DataSource.
This returns a Datasource.Factory object:
return new DefaultDataSourceFactory(this, null, new DefaultHttpDataSourceFactory(Util.getUserAgent(mContext, "appAgent"), null));
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