Search in sources :

Example 1 with TrackSelector

use of com.google.android.exoplayer2.trackselection.TrackSelector in project ExoPlayer by google.

the class ExoHostedTest method onStart.

// HostedTest implementation
@Override
public final void onStart(HostActivity host, Surface surface) {
    // Build the player.
    DefaultBandwidthMeter bandwidthMeter = new DefaultBandwidthMeter();
    trackSelector = buildTrackSelector(host, bandwidthMeter);
    String userAgent = "ExoPlayerPlaybackTests";
    DrmSessionManager<FrameworkMediaCrypto> drmSessionManager = buildDrmSessionManager(userAgent);
    player = buildExoPlayer(host, surface, trackSelector, drmSessionManager);
    player.prepare(buildSource(host, Util.getUserAgent(host, userAgent), bandwidthMeter));
    player.addListener(this);
    player.setAudioDebugListener(this);
    player.setVideoDebugListener(this);
    player.setPlayWhenReady(true);
    actionHandler = new Handler();
    // Schedule any pending actions.
    if (pendingSchedule != null) {
        pendingSchedule.start(player, trackSelector, actionHandler);
        pendingSchedule = null;
    }
}
Also used : DefaultBandwidthMeter(com.google.android.exoplayer2.upstream.DefaultBandwidthMeter) FrameworkMediaCrypto(com.google.android.exoplayer2.drm.FrameworkMediaCrypto) Handler(android.os.Handler)

Example 2 with TrackSelector

use of com.google.android.exoplayer2.trackselection.TrackSelector in project instructure-android by instructure.

the class VideoViewActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_video_view);
    simpleExoPlayerView = (SimpleExoPlayerView) findViewById(R.id.player_view);
    simpleExoPlayerView.requestFocus();
    mediaDataSourceFactory = buildDataSourceFactory(true);
    mainHandler = new Handler();
    TrackSelection.Factory videoTrackSelectionFactory = new AdaptiveVideoTrackSelection.Factory(BANDWIDTH_METER);
    trackSelector = new DefaultTrackSelector(videoTrackSelectionFactory);
    player = ExoPlayerFactory.newSimpleInstance(this, trackSelector, new DefaultLoadControl());
    simpleExoPlayerView.setPlayer(player);
    player.setPlayWhenReady(true);
    player.prepare(buildMediaSource(Uri.parse(getIntent().getExtras().getString(Const.URL)), ""));
}
Also used : Handler(android.os.Handler) DefaultHttpDataSourceFactory(com.google.android.exoplayer2.upstream.DefaultHttpDataSourceFactory) DefaultDataSourceFactory(com.google.android.exoplayer2.upstream.DefaultDataSourceFactory) ExoPlayerFactory(com.google.android.exoplayer2.ExoPlayerFactory) DefaultExtractorsFactory(com.google.android.exoplayer2.extractor.DefaultExtractorsFactory) DefaultTrackSelector(com.google.android.exoplayer2.trackselection.DefaultTrackSelector) TrackSelection(com.google.android.exoplayer2.trackselection.TrackSelection) AdaptiveVideoTrackSelection(com.google.android.exoplayer2.trackselection.AdaptiveVideoTrackSelection) DefaultLoadControl(com.google.android.exoplayer2.DefaultLoadControl)

Example 3 with TrackSelector

use of com.google.android.exoplayer2.trackselection.TrackSelector in project PainlessMusicPlayer by Doctoror.

the class ExoMediaPlayer method init.

@Override
public void init(@NonNull final Context context) {
    final TrackSelector trackSelector = new DefaultTrackSelector();
    exoPlayer = ExoPlayerFactory.newSimpleInstance(new DefaultRenderersFactory(context), trackSelector, new DefaultLoadControl());
    exoPlayer.addListener(mEventListener);
    exoPlayer.addAudioDebugListener(mAudioRendererEventListener);
    dataSourceFactory = new DefaultDataSourceFactory(context, Util.getUserAgent(context, "Fuck Off Music Player"));
}
Also used : DefaultDataSourceFactory(com.google.android.exoplayer2.upstream.DefaultDataSourceFactory) TrackSelector(com.google.android.exoplayer2.trackselection.TrackSelector) DefaultTrackSelector(com.google.android.exoplayer2.trackselection.DefaultTrackSelector) DefaultTrackSelector(com.google.android.exoplayer2.trackselection.DefaultTrackSelector) DefaultRenderersFactory(com.google.android.exoplayer2.DefaultRenderersFactory) DefaultLoadControl(com.google.android.exoplayer2.DefaultLoadControl)

Example 4 with TrackSelector

use of com.google.android.exoplayer2.trackselection.TrackSelector 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)

Example 5 with TrackSelector

use of com.google.android.exoplayer2.trackselection.TrackSelector in project react-native-video by react-native-community.

the class ReactExoplayerView method initializePlayer.

// Internal methods
private void initializePlayer() {
    if (player == null) {
        TrackSelection.Factory videoTrackSelectionFactory = new AdaptiveTrackSelection.Factory(BANDWIDTH_METER);
        trackSelector = new DefaultTrackSelector(videoTrackSelectionFactory);
        player = ExoPlayerFactory.newSimpleInstance(getContext(), trackSelector, new DefaultLoadControl());
        player.addListener(this);
        player.setMetadataOutput(this);
        exoPlayerView.setPlayer(player);
        audioBecomingNoisyReceiver.setListener(this);
        setPlayWhenReady(!isPaused);
        playerNeedsSource = true;
        PlaybackParameters params = new PlaybackParameters(rate, 1f);
        player.setPlaybackParameters(params);
    }
    if (playerNeedsSource && srcUri != null) {
        MediaSource mediaSource = buildMediaSource(srcUri, extension);
        mediaSource = repeat ? new LoopingMediaSource(mediaSource) : mediaSource;
        boolean haveResumePosition = resumeWindow != C.INDEX_UNSET;
        if (haveResumePosition) {
            player.seekTo(resumeWindow, resumePosition);
        }
        player.prepare(mediaSource, !haveResumePosition, false);
        playerNeedsSource = false;
        eventEmitter.loadStart();
        loadVideoStarted = true;
    }
}
Also used : DashMediaSource(com.google.android.exoplayer2.source.dash.DashMediaSource) MediaSource(com.google.android.exoplayer2.source.MediaSource) SsMediaSource(com.google.android.exoplayer2.source.smoothstreaming.SsMediaSource) HlsMediaSource(com.google.android.exoplayer2.source.hls.HlsMediaSource) ExtractorMediaSource(com.google.android.exoplayer2.source.ExtractorMediaSource) LoopingMediaSource(com.google.android.exoplayer2.source.LoopingMediaSource) DefaultExtractorsFactory(com.google.android.exoplayer2.extractor.DefaultExtractorsFactory) ExoPlayerFactory(com.google.android.exoplayer2.ExoPlayerFactory) DefaultTrackSelector(com.google.android.exoplayer2.trackselection.DefaultTrackSelector) TrackSelection(com.google.android.exoplayer2.trackselection.TrackSelection) AdaptiveTrackSelection(com.google.android.exoplayer2.trackselection.AdaptiveTrackSelection) DefaultLoadControl(com.google.android.exoplayer2.DefaultLoadControl) PlaybackParameters(com.google.android.exoplayer2.PlaybackParameters) LoopingMediaSource(com.google.android.exoplayer2.source.LoopingMediaSource)

Aggregations

DefaultTrackSelector (com.google.android.exoplayer2.trackselection.DefaultTrackSelector)16 DefaultLoadControl (com.google.android.exoplayer2.DefaultLoadControl)11 Test (org.junit.Test)10 MediaSource (com.google.android.exoplayer2.source.MediaSource)8 ExoPlayerFactory (com.google.android.exoplayer2.ExoPlayerFactory)7 TrackGroupArray (com.google.android.exoplayer2.source.TrackGroupArray)7 AdaptiveTrackSelection (com.google.android.exoplayer2.trackselection.AdaptiveTrackSelection)7 TrackSelection (com.google.android.exoplayer2.trackselection.TrackSelection)7 DefaultRenderersFactory (com.google.android.exoplayer2.DefaultRenderersFactory)6 ExoPlayer (com.google.android.exoplayer2.ExoPlayer)6 RendererCapabilities (com.google.android.exoplayer2.RendererCapabilities)5 ConcatenatingMediaSource (com.google.android.exoplayer2.source.ConcatenatingMediaSource)5 TrackGroup (com.google.android.exoplayer2.source.TrackGroup)5 TrackSelector (com.google.android.exoplayer2.trackselection.TrackSelector)5 LoadControl (com.google.android.exoplayer2.LoadControl)4 SimpleExoPlayer (com.google.android.exoplayer2.SimpleExoPlayer)4 ClippingMediaSource (com.google.android.exoplayer2.source.ClippingMediaSource)4 CompositeMediaSource (com.google.android.exoplayer2.source.CompositeMediaSource)4 MaskingMediaSource (com.google.android.exoplayer2.source.MaskingMediaSource)4 ServerSideAdInsertionMediaSource (com.google.android.exoplayer2.source.ads.ServerSideAdInsertionMediaSource)4