Search in sources :

Example 1 with LoopingMediaSource

use of com.google.android.exoplayer2.source.LoopingMediaSource 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 AdaptiveVideoTrackSelection.Factory(BANDWIDTH_METER);
        trackSelector = new DefaultTrackSelector(videoTrackSelectionFactory);
        player = ExoPlayerFactory.newSimpleInstance(getContext(), trackSelector, new DefaultLoadControl());
        player.addListener(this);
        player.setMetadataOutput(this);
        exoPlayerView.setPlayer(player);
        if (isTimelineStatic) {
            if (playerPosition == C.TIME_UNSET) {
                player.seekToDefaultPosition(playerWindow);
            } else {
                player.seekTo(playerWindow, playerPosition);
            }
        }
        audioBecomingNoisyReceiver.setListener(this);
        setPlayWhenReady(!isPaused);
        playerNeedsSource = true;
    }
    if (playerNeedsSource && srcUri != null) {
        MediaSource mediaSource = buildMediaSource(srcUri, extension);
        mediaSource = repeat ? new LoopingMediaSource(mediaSource) : mediaSource;
        player.prepare(mediaSource, !shouldRestorePosition, true);
        playerNeedsSource = false;
        eventEmitter.loadStart();
        loadVideoStarted = true;
    }
}
Also used : HlsMediaSource(com.google.android.exoplayer2.source.hls.HlsMediaSource) DashMediaSource(com.google.android.exoplayer2.source.dash.DashMediaSource) ExtractorMediaSource(com.google.android.exoplayer2.source.ExtractorMediaSource) MediaSource(com.google.android.exoplayer2.source.MediaSource) LoopingMediaSource(com.google.android.exoplayer2.source.LoopingMediaSource) SsMediaSource(com.google.android.exoplayer2.source.smoothstreaming.SsMediaSource) 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) LoopingMediaSource(com.google.android.exoplayer2.source.LoopingMediaSource)

Aggregations

DefaultLoadControl (com.google.android.exoplayer2.DefaultLoadControl)1 ExoPlayerFactory (com.google.android.exoplayer2.ExoPlayerFactory)1 DefaultExtractorsFactory (com.google.android.exoplayer2.extractor.DefaultExtractorsFactory)1 ExtractorMediaSource (com.google.android.exoplayer2.source.ExtractorMediaSource)1 LoopingMediaSource (com.google.android.exoplayer2.source.LoopingMediaSource)1 MediaSource (com.google.android.exoplayer2.source.MediaSource)1 DashMediaSource (com.google.android.exoplayer2.source.dash.DashMediaSource)1 HlsMediaSource (com.google.android.exoplayer2.source.hls.HlsMediaSource)1 SsMediaSource (com.google.android.exoplayer2.source.smoothstreaming.SsMediaSource)1 AdaptiveVideoTrackSelection (com.google.android.exoplayer2.trackselection.AdaptiveVideoTrackSelection)1 DefaultTrackSelector (com.google.android.exoplayer2.trackselection.DefaultTrackSelector)1 TrackSelection (com.google.android.exoplayer2.trackselection.TrackSelection)1