Search in sources :

Example 1 with PlaybackParameters

use of com.google.android.exoplayer2.PlaybackParameters in project RandomWebm by alkocher.

the class RandomFragment method initPlayer.

private void initPlayer(String VIDEO_URL) {
    playerView.setPlayer(player);
    MediaSource mediaSource = new ExtractorMediaSource.Factory(dataSourceFactory).createMediaSource(Uri.parse(VIDEO_URL));
    player.prepare(mediaSource);
    player.setPlayWhenReady(true);
    // Progress bar
    player.addListener(new ExoPlayer.EventListener() {

        @Override
        public void onTimelineChanged(Timeline timeline, Object manifest) {
        }

        @Override
        public void onTracksChanged(TrackGroupArray trackGroups, TrackSelectionArray trackSelections) {
        }

        @Override
        public void onLoadingChanged(boolean isLoading) {
        }

        @Override
        public void onPlayerStateChanged(boolean playWhenReady, int playbackState) {
            if (playbackState == ExoPlayer.STATE_BUFFERING) {
                progressBar.setVisibility(View.VISIBLE);
            } else {
                progressBar.setVisibility(View.GONE);
            }
        }

        @Override
        public void onRepeatModeChanged(int repeatMode) {
        }

        @Override
        public void onShuffleModeEnabledChanged(boolean shuffleModeEnabled) {
        }

        @Override
        public void onPlayerError(ExoPlaybackException error) {
        }

        @Override
        public void onPositionDiscontinuity(int reason) {
        }

        @Override
        public void onPlaybackParametersChanged(PlaybackParameters playbackParameters) {
        }

        @Override
        public void onSeekProcessed() {
        }
    });
}
Also used : TrackGroupArray(com.google.android.exoplayer2.source.TrackGroupArray) ExoPlaybackException(com.google.android.exoplayer2.ExoPlaybackException) ExtractorMediaSource(com.google.android.exoplayer2.source.ExtractorMediaSource) SimpleExoPlayer(com.google.android.exoplayer2.SimpleExoPlayer) ExoPlayer(com.google.android.exoplayer2.ExoPlayer) TrackSelectionArray(com.google.android.exoplayer2.trackselection.TrackSelectionArray) Timeline(com.google.android.exoplayer2.Timeline) MediaSource(com.google.android.exoplayer2.source.MediaSource) ExtractorMediaSource(com.google.android.exoplayer2.source.ExtractorMediaSource) PlaybackParameters(com.google.android.exoplayer2.PlaybackParameters)

Example 2 with PlaybackParameters

use of com.google.android.exoplayer2.PlaybackParameters in project RandomWebm by alkocher.

the class PlayerActivity method initPlayer.

private void initPlayer(String VIDEO_URL) {
    playerView.setPlayer(player);
    MediaSource mediaSource = new ExtractorMediaSource.Factory(dataSourceFactory).createMediaSource(Uri.parse(VIDEO_URL));
    player.prepare(mediaSource);
    player.setPlayWhenReady(true);
    // Loading Bar
    player.addListener(new ExoPlayer.EventListener() {

        @Override
        public void onTimelineChanged(Timeline timeline, Object manifest) {
        }

        @Override
        public void onTracksChanged(TrackGroupArray trackGroups, TrackSelectionArray trackSelections) {
        }

        @Override
        public void onLoadingChanged(boolean isLoading) {
        }

        @Override
        public void onRepeatModeChanged(int repeatMode) {
        }

        @Override
        public void onShuffleModeEnabledChanged(boolean shuffleModeEnabled) {
        }

        @Override
        public void onPlayerError(ExoPlaybackException error) {
        }

        @Override
        public void onPositionDiscontinuity(int reason) {
        }

        @Override
        public void onPlaybackParametersChanged(PlaybackParameters playbackParameters) {
        }

        @Override
        public void onSeekProcessed() {
        }

        @Override
        public void onPlayerStateChanged(boolean playWhenReady, int playbackState) {
            if (playbackState == ExoPlayer.STATE_BUFFERING) {
                progressBar.setVisibility(View.VISIBLE);
            } else {
                progressBar.setVisibility(View.INVISIBLE);
            }
        }
    });
}
Also used : TrackGroupArray(com.google.android.exoplayer2.source.TrackGroupArray) ExoPlaybackException(com.google.android.exoplayer2.ExoPlaybackException) ExtractorMediaSource(com.google.android.exoplayer2.source.ExtractorMediaSource) SimpleExoPlayer(com.google.android.exoplayer2.SimpleExoPlayer) ExoPlayer(com.google.android.exoplayer2.ExoPlayer) TrackSelectionArray(com.google.android.exoplayer2.trackselection.TrackSelectionArray) Timeline(com.google.android.exoplayer2.Timeline) ExtractorMediaSource(com.google.android.exoplayer2.source.ExtractorMediaSource) MediaSource(com.google.android.exoplayer2.source.MediaSource) PlaybackParameters(com.google.android.exoplayer2.PlaybackParameters)

Example 3 with PlaybackParameters

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

Example 4 with PlaybackParameters

use of com.google.android.exoplayer2.PlaybackParameters in project NewPipe by TeamNewPipe.

the class BasePlayer method getPlaybackParameters.

public PlaybackParameters getPlaybackParameters() {
    final PlaybackParameters defaultParameters = new PlaybackParameters(1f, 1f);
    if (simpleExoPlayer == null)
        return defaultParameters;
    final PlaybackParameters parameters = simpleExoPlayer.getPlaybackParameters();
    return parameters == null ? defaultParameters : parameters;
}
Also used : PlaybackParameters(com.google.android.exoplayer2.PlaybackParameters)

Example 5 with PlaybackParameters

use of com.google.android.exoplayer2.PlaybackParameters in project AntennaPod by AntennaPod.

the class ExoPlayerWrapper method setPlaybackParams.

@Override
public void setPlaybackParams(float speed, boolean skipSilence) {
    playbackParameters = new PlaybackParameters(speed, playbackParameters.pitch);
    exoPlayer.setSkipSilenceEnabled(skipSilence);
    exoPlayer.setPlaybackParameters(playbackParameters);
}
Also used : PlaybackParameters(com.google.android.exoplayer2.PlaybackParameters)

Aggregations

PlaybackParameters (com.google.android.exoplayer2.PlaybackParameters)20 Test (org.junit.Test)17 Listener (com.google.android.exoplayer2.Player.Listener)7 FakeMediaSource (com.google.android.exoplayer2.testutil.FakeMediaSource)7 FakeTimeline (com.google.android.exoplayer2.testutil.FakeTimeline)7 TestExoPlayerBuilder (com.google.android.exoplayer2.testutil.TestExoPlayerBuilder)7 MediaSource (com.google.android.exoplayer2.source.MediaSource)4 ArrayList (java.util.ArrayList)4 Nullable (androidx.annotation.Nullable)3 ExoPlayer (com.google.android.exoplayer2.ExoPlayer)3 ExtractorMediaSource (com.google.android.exoplayer2.source.ExtractorMediaSource)3 SinglePeriodTimeline (com.google.android.exoplayer2.source.SinglePeriodTimeline)3 TrackGroupArray (com.google.android.exoplayer2.source.TrackGroupArray)3 ActionSchedule (com.google.android.exoplayer2.testutil.ActionSchedule)3 ExoPlayerTestRunner (com.google.android.exoplayer2.testutil.ExoPlayerTestRunner)3 FakeMediaClockRenderer (com.google.android.exoplayer2.testutil.FakeMediaClockRenderer)3 TransferListener (com.google.android.exoplayer2.upstream.TransferListener)3 Surface (android.view.Surface)2 ExoPlaybackException (com.google.android.exoplayer2.ExoPlaybackException)2 SimpleExoPlayer (com.google.android.exoplayer2.SimpleExoPlayer)2