Search in sources :

Example 1 with AttachmentDataSourceFactory

use of org.thoughtcrime.securesms.video.exo.AttachmentDataSourceFactory in project Signal-Android by signalapp.

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(getContext(), defaultDataSourceFactory, null);
    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)

Aggregations

DefaultLoadControl (com.google.android.exoplayer2.DefaultLoadControl)1 ExoPlayerFactory (com.google.android.exoplayer2.ExoPlayerFactory)1 LoadControl (com.google.android.exoplayer2.LoadControl)1 DefaultExtractorsFactory (com.google.android.exoplayer2.extractor.DefaultExtractorsFactory)1 ExtractorsFactory (com.google.android.exoplayer2.extractor.ExtractorsFactory)1 ExtractorMediaSource (com.google.android.exoplayer2.source.ExtractorMediaSource)1 MediaSource (com.google.android.exoplayer2.source.MediaSource)1 AdaptiveTrackSelection (com.google.android.exoplayer2.trackselection.AdaptiveTrackSelection)1 DefaultTrackSelector (com.google.android.exoplayer2.trackselection.DefaultTrackSelector)1 TrackSelection (com.google.android.exoplayer2.trackselection.TrackSelection)1 TrackSelector (com.google.android.exoplayer2.trackselection.TrackSelector)1 BandwidthMeter (com.google.android.exoplayer2.upstream.BandwidthMeter)1 DefaultBandwidthMeter (com.google.android.exoplayer2.upstream.DefaultBandwidthMeter)1 DefaultDataSourceFactory (com.google.android.exoplayer2.upstream.DefaultDataSourceFactory)1 AttachmentDataSourceFactory (org.thoughtcrime.securesms.video.exo.AttachmentDataSourceFactory)1