Search in sources :

Example 11 with DefaultExtractorsFactory

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);
}
Also used : DefaultExtractorsFactory(com.google.android.exoplayer2.extractor.DefaultExtractorsFactory) HashMap(java.util.HashMap) OkHttpDataSource(com.google.android.exoplayer2.ext.okhttp.OkHttpDataSource) ProgressiveMediaSource(com.google.android.exoplayer2.source.ProgressiveMediaSource) DefaultDataSourceFactory(com.google.android.exoplayer2.upstream.DefaultDataSourceFactory) DefaultExtractorsFactory(com.google.android.exoplayer2.extractor.DefaultExtractorsFactory) DefaultRenderersFactory(com.google.android.exoplayer2.DefaultRenderersFactory) DataSource(com.google.android.exoplayer2.upstream.DataSource) OkHttpDataSource(com.google.android.exoplayer2.ext.okhttp.OkHttpDataSource) HttpDataSource(com.google.android.exoplayer2.upstream.HttpDataSource) DefaultDataSourceFactory(com.google.android.exoplayer2.upstream.DefaultDataSourceFactory) MediaItem(com.google.android.exoplayer2.MediaItem)

Aggregations

DefaultExtractorsFactory (com.google.android.exoplayer2.extractor.DefaultExtractorsFactory)9 MediaSource (com.google.android.exoplayer2.source.MediaSource)7 DataSource (com.google.android.exoplayer2.upstream.DataSource)7 DefaultDataSourceFactory (com.google.android.exoplayer2.upstream.DefaultDataSourceFactory)7 ExtractorsFactory (com.google.android.exoplayer2.extractor.ExtractorsFactory)6 ExtractorMediaSource (com.google.android.exoplayer2.source.ExtractorMediaSource)6 DefaultTrackSelector (com.google.android.exoplayer2.trackselection.DefaultTrackSelector)6 DefaultLoadControl (com.google.android.exoplayer2.DefaultLoadControl)5 Uri (android.net.Uri)3 DefaultRenderersFactory (com.google.android.exoplayer2.DefaultRenderersFactory)3 AudioAttributes (com.google.android.exoplayer2.audio.AudioAttributes)3 AmrExtractor (com.google.android.exoplayer2.extractor.amr.AmrExtractor)2 FlacExtractor (com.google.android.exoplayer2.extractor.flac.FlacExtractor)2 FlvExtractor (com.google.android.exoplayer2.extractor.flv.FlvExtractor)2 JpegExtractor (com.google.android.exoplayer2.extractor.jpeg.JpegExtractor)2 MatroskaExtractor (com.google.android.exoplayer2.extractor.mkv.MatroskaExtractor)2 Mp3Extractor (com.google.android.exoplayer2.extractor.mp3.Mp3Extractor)2 FragmentedMp4Extractor (com.google.android.exoplayer2.extractor.mp4.FragmentedMp4Extractor)2 Mp4Extractor (com.google.android.exoplayer2.extractor.mp4.Mp4Extractor)2 OggExtractor (com.google.android.exoplayer2.extractor.ogg.OggExtractor)2