Search in sources :

Example 6 with DefaultExtractorsFactory

use of androidx.media3.extractor.DefaultExtractorsFactory in project jellyfin-androidtv by jellyfin.

the class VideoManager method configureExoplayerBuilder.

/**
 * Configures Exoplayer for video playback. Initially we try with core decoders, but allow
 * ExoPlayer to silently fallback to software renderers.
 *
 * @param context The associated context
 * @return A configured builder for Exoplayer
 */
private ExoPlayer.Builder configureExoplayerBuilder(Context context) {
    ExoPlayer.Builder exoPlayerBuilder = new ExoPlayer.Builder(context);
    DefaultRenderersFactory defaultRendererFactory = new DefaultRenderersFactory(context);
    defaultRendererFactory.setEnableDecoderFallback(true);
    defaultRendererFactory.setExtensionRendererMode(DefaultRenderersFactory.EXTENSION_RENDERER_MODE_ON);
    exoPlayerBuilder.setRenderersFactory(defaultRendererFactory);
    DefaultExtractorsFactory defaultExtractorsFactory = new DefaultExtractorsFactory().setTsExtractorTimestampSearchBytes(TsExtractor.DEFAULT_TIMESTAMP_SEARCH_BYTES * 3);
    exoPlayerBuilder.setMediaSourceFactory(new DefaultMediaSourceFactory(context, defaultExtractorsFactory));
    return exoPlayerBuilder;
}
Also used : DefaultExtractorsFactory(com.google.android.exoplayer2.extractor.DefaultExtractorsFactory) DefaultMediaSourceFactory(com.google.android.exoplayer2.source.DefaultMediaSourceFactory) ExoPlayer(com.google.android.exoplayer2.ExoPlayer) DefaultRenderersFactory(com.google.android.exoplayer2.DefaultRenderersFactory)

Example 7 with DefaultExtractorsFactory

use of androidx.media3.extractor.DefaultExtractorsFactory in project deltachat-android by deltachat.

the class AudioSlidePlayer method createMediaSource.

private MediaSource createMediaSource(@NonNull Uri uri) {
    DefaultDataSourceFactory defaultDataSourceFactory = new DefaultDataSourceFactory(context, "GenericUserAgent", null);
    AttachmentDataSourceFactory attachmentDataSourceFactory = new AttachmentDataSourceFactory(defaultDataSourceFactory);
    ExtractorsFactory extractorsFactory = new DefaultExtractorsFactory().setConstantBitrateSeekingEnabled(true);
    return new ExtractorMediaSource.Factory(attachmentDataSourceFactory).setExtractorsFactory(extractorsFactory).createMediaSource(uri);
}
Also used : DefaultExtractorsFactory(com.google.android.exoplayer2.extractor.DefaultExtractorsFactory) ExtractorsFactory(com.google.android.exoplayer2.extractor.ExtractorsFactory) DefaultExtractorsFactory(com.google.android.exoplayer2.extractor.DefaultExtractorsFactory) DefaultDataSourceFactory(com.google.android.exoplayer2.upstream.DefaultDataSourceFactory) AttachmentDataSourceFactory(org.thoughtcrime.securesms.video.exo.AttachmentDataSourceFactory) DefaultDataSourceFactory(com.google.android.exoplayer2.upstream.DefaultDataSourceFactory) ExoPlayerFactory(com.google.android.exoplayer2.ExoPlayerFactory) DefaultRenderersFactory(com.google.android.exoplayer2.DefaultRenderersFactory) ExtractorsFactory(com.google.android.exoplayer2.extractor.ExtractorsFactory) DefaultExtractorsFactory(com.google.android.exoplayer2.extractor.DefaultExtractorsFactory) AttachmentDataSourceFactory(org.thoughtcrime.securesms.video.exo.AttachmentDataSourceFactory)

Example 8 with DefaultExtractorsFactory

use of androidx.media3.extractor.DefaultExtractorsFactory in project deltachat-android by deltachat.

the class VideoPlayer method setExoViewSource.

private void setExoViewSource(@NonNull VideoSlide videoSource, boolean autoplay) throws IOException {
    BandwidthMeter bandwidthMeter = new DefaultBandwidthMeter();
    TrackSelection.Factory videoTrackSelectionFactory = new AdaptiveTrackSelection.Factory(bandwidthMeter);
    TrackSelector trackSelector = new DefaultTrackSelector(videoTrackSelectionFactory);
    LoadControl loadControl = new DefaultLoadControl();
    exoPlayer = ExoPlayerFactory.newSimpleInstance(getContext(), trackSelector, loadControl);
    exoPlayer.addListener(new ExoPlayerListener(window));
    // noinspection ConstantConditions
    exoView.setPlayer(exoPlayer);
    DefaultDataSourceFactory defaultDataSourceFactory = new DefaultDataSourceFactory(getContext(), "GenericUserAgent", null);
    AttachmentDataSourceFactory attachmentDataSourceFactory = new AttachmentDataSourceFactory(defaultDataSourceFactory);
    ExtractorsFactory extractorsFactory = new DefaultExtractorsFactory();
    MediaSource mediaSource = new ExtractorMediaSource(videoSource.getUri(), attachmentDataSourceFactory, extractorsFactory, null, null);
    exoPlayer.prepare(mediaSource);
    exoPlayer.setPlayWhenReady(autoplay);
}
Also used : DefaultExtractorsFactory(com.google.android.exoplayer2.extractor.DefaultExtractorsFactory) DefaultBandwidthMeter(com.google.android.exoplayer2.upstream.DefaultBandwidthMeter) DefaultLoadControl(com.google.android.exoplayer2.DefaultLoadControl) LoadControl(com.google.android.exoplayer2.LoadControl) TrackSelector(com.google.android.exoplayer2.trackselection.TrackSelector) DefaultTrackSelector(com.google.android.exoplayer2.trackselection.DefaultTrackSelector) AttachmentDataSourceFactory(org.thoughtcrime.securesms.video.exo.AttachmentDataSourceFactory) DefaultDataSourceFactory(com.google.android.exoplayer2.upstream.DefaultDataSourceFactory) ExoPlayerFactory(com.google.android.exoplayer2.ExoPlayerFactory) ExtractorsFactory(com.google.android.exoplayer2.extractor.ExtractorsFactory) DefaultExtractorsFactory(com.google.android.exoplayer2.extractor.DefaultExtractorsFactory) ExtractorMediaSource(com.google.android.exoplayer2.source.ExtractorMediaSource) DefaultLoadControl(com.google.android.exoplayer2.DefaultLoadControl) ExtractorMediaSource(com.google.android.exoplayer2.source.ExtractorMediaSource) MediaSource(com.google.android.exoplayer2.source.MediaSource) ExtractorsFactory(com.google.android.exoplayer2.extractor.ExtractorsFactory) DefaultExtractorsFactory(com.google.android.exoplayer2.extractor.DefaultExtractorsFactory) DefaultDataSourceFactory(com.google.android.exoplayer2.upstream.DefaultDataSourceFactory) BandwidthMeter(com.google.android.exoplayer2.upstream.BandwidthMeter) DefaultBandwidthMeter(com.google.android.exoplayer2.upstream.DefaultBandwidthMeter) DefaultTrackSelector(com.google.android.exoplayer2.trackselection.DefaultTrackSelector) TrackSelection(com.google.android.exoplayer2.trackselection.TrackSelection) AdaptiveTrackSelection(com.google.android.exoplayer2.trackselection.AdaptiveTrackSelection) AttachmentDataSourceFactory(org.thoughtcrime.securesms.video.exo.AttachmentDataSourceFactory)

Example 9 with DefaultExtractorsFactory

use of androidx.media3.extractor.DefaultExtractorsFactory in project TV-youtube by chiou711.

the class PlaybackFragment method prepareMediaForPlaying.

private void prepareMediaForPlaying(Uri mediaSourceUri) {
    String userAgent = Util.getUserAgent(getActivity(), "VideoPlayerGlue");
    MediaSource mediaSource = new ExtractorMediaSource(mediaSourceUri, new DefaultDataSourceFactory(getActivity(), userAgent), new DefaultExtractorsFactory(), null, null);
    mPlayer.prepare(mediaSource);
}
Also used : DefaultExtractorsFactory(com.google.android.exoplayer2.extractor.DefaultExtractorsFactory) ExtractorMediaSource(com.google.android.exoplayer2.source.ExtractorMediaSource) MediaSource(com.google.android.exoplayer2.source.MediaSource) DefaultDataSourceFactory(com.google.android.exoplayer2.upstream.DefaultDataSourceFactory) ExtractorMediaSource(com.google.android.exoplayer2.source.ExtractorMediaSource)

Example 10 with DefaultExtractorsFactory

use of androidx.media3.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)20 DefaultDataSourceFactory (com.google.android.exoplayer2.upstream.DefaultDataSourceFactory)13 ExtractorMediaSource (com.google.android.exoplayer2.source.ExtractorMediaSource)12 MediaSource (com.google.android.exoplayer2.source.MediaSource)12 ExtractorsFactory (com.google.android.exoplayer2.extractor.ExtractorsFactory)11 DefaultRenderersFactory (com.google.android.exoplayer2.DefaultRenderersFactory)10 DefaultTrackSelector (com.google.android.exoplayer2.trackselection.DefaultTrackSelector)9 DefaultLoadControl (com.google.android.exoplayer2.DefaultLoadControl)8 DataSource (com.google.android.exoplayer2.upstream.DataSource)8 ExoPlayerFactory (com.google.android.exoplayer2.ExoPlayerFactory)7 Uri (android.net.Uri)5 LoadControl (com.google.android.exoplayer2.LoadControl)4 AudioAttributes (com.google.android.exoplayer2.audio.AudioAttributes)4 DashMediaSource (com.google.android.exoplayer2.source.dash.DashMediaSource)4 HlsMediaSource (com.google.android.exoplayer2.source.hls.HlsMediaSource)4 SsMediaSource (com.google.android.exoplayer2.source.smoothstreaming.SsMediaSource)4 AdaptiveTrackSelection (com.google.android.exoplayer2.trackselection.AdaptiveTrackSelection)4 HashMap (java.util.HashMap)4 SuppressLint (android.annotation.SuppressLint)3 DefaultHttpDataSourceFactory (com.google.android.exoplayer2.upstream.DefaultHttpDataSourceFactory)3