use of com.google.android.exoplayer2.extractor.DefaultExtractorsFactory in project AntennaPod by AntennaPod.
the class ExoPlayerWrapper method setDataSource.
public void setDataSource(String s, String user, String password) throws IllegalArgumentException, IllegalStateException {
Log.d(TAG, "setDataSource: " + s);
final OkHttpDataSource.Factory httpDataSourceFactory = new OkHttpDataSource.Factory(AntennapodHttpClient.getHttpClient()).setUserAgent(ClientConfig.USER_AGENT);
if (!TextUtils.isEmpty(user) && !TextUtils.isEmpty(password)) {
final HashMap<String, String> requestProperties = new HashMap<>();
requestProperties.put("Authorization", HttpDownloader.encodeCredentials(user, password, "ISO-8859-1"));
httpDataSourceFactory.setDefaultRequestProperties(requestProperties);
}
DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(context, null, httpDataSourceFactory);
DefaultExtractorsFactory extractorsFactory = new DefaultExtractorsFactory();
extractorsFactory.setConstantBitrateSeekingEnabled(true);
extractorsFactory.setMp3ExtractorFlags(Mp3Extractor.FLAG_DISABLE_ID3_METADATA);
ProgressiveMediaSource.Factory f = new ProgressiveMediaSource.Factory(dataSourceFactory, extractorsFactory);
final MediaItem mediaItem = MediaItem.fromUri(Uri.parse(s));
mediaSource = f.createMediaSource(mediaItem);
}
Aggregations