Search in sources :

Example 1 with CustomTrackSelector

use of org.schabi.newpipe.player.playback.CustomTrackSelector in project NewPipe by TeamNewPipe.

the class BasePlayer method initPlayer.

public void initPlayer() {
    if (DEBUG)
        Log.d(TAG, "initPlayer() called with: context = [" + context + "]");
    if (databaseUpdateReactor != null)
        databaseUpdateReactor.dispose();
    databaseUpdateReactor = new CompositeDisposable();
    final String userAgent = Downloader.USER_AGENT;
    final DefaultBandwidthMeter bandwidthMeter = new DefaultBandwidthMeter();
    dataSource = new PlayerDataSource(context, userAgent, bandwidthMeter);
    final AdaptiveTrackSelection.Factory trackSelectionFactory = new AdaptiveTrackSelection.Factory(bandwidthMeter);
    trackSelector = new CustomTrackSelector(trackSelectionFactory);
    final LoadControl loadControl = new LoadController(context);
    final RenderersFactory renderFactory = new DefaultRenderersFactory(context);
    simpleExoPlayer = ExoPlayerFactory.newSimpleInstance(renderFactory, trackSelector, loadControl);
    simpleExoPlayer.addListener(this);
    simpleExoPlayer.setPlayWhenReady(true);
    simpleExoPlayer.setSeekParameters(PlayerHelper.getSeekParameters(context));
    audioReactor = new AudioReactor(context, simpleExoPlayer);
    mediaSessionManager = new MediaSessionManager(context, simpleExoPlayer, new BasePlayerMediaSession(this));
}
Also used : DefaultBandwidthMeter(com.google.android.exoplayer2.upstream.DefaultBandwidthMeter) LoadControl(com.google.android.exoplayer2.LoadControl) RenderersFactory(com.google.android.exoplayer2.RenderersFactory) ExoPlayerFactory(com.google.android.exoplayer2.ExoPlayerFactory) DefaultRenderersFactory(com.google.android.exoplayer2.DefaultRenderersFactory) MediaSessionManager(org.schabi.newpipe.player.helper.MediaSessionManager) PlayerHelper.getTimeString(org.schabi.newpipe.player.helper.PlayerHelper.getTimeString) RenderersFactory(com.google.android.exoplayer2.RenderersFactory) DefaultRenderersFactory(com.google.android.exoplayer2.DefaultRenderersFactory) AudioReactor(org.schabi.newpipe.player.helper.AudioReactor) BasePlayerMediaSession(org.schabi.newpipe.player.playback.BasePlayerMediaSession) PlayerDataSource(org.schabi.newpipe.player.helper.PlayerDataSource) AdaptiveTrackSelection(com.google.android.exoplayer2.trackselection.AdaptiveTrackSelection) CustomTrackSelector(org.schabi.newpipe.player.playback.CustomTrackSelector) DefaultRenderersFactory(com.google.android.exoplayer2.DefaultRenderersFactory) CompositeDisposable(io.reactivex.disposables.CompositeDisposable) LoadController(org.schabi.newpipe.player.helper.LoadController)

Aggregations

DefaultRenderersFactory (com.google.android.exoplayer2.DefaultRenderersFactory)1 ExoPlayerFactory (com.google.android.exoplayer2.ExoPlayerFactory)1 LoadControl (com.google.android.exoplayer2.LoadControl)1 RenderersFactory (com.google.android.exoplayer2.RenderersFactory)1 AdaptiveTrackSelection (com.google.android.exoplayer2.trackselection.AdaptiveTrackSelection)1 DefaultBandwidthMeter (com.google.android.exoplayer2.upstream.DefaultBandwidthMeter)1 CompositeDisposable (io.reactivex.disposables.CompositeDisposable)1 AudioReactor (org.schabi.newpipe.player.helper.AudioReactor)1 LoadController (org.schabi.newpipe.player.helper.LoadController)1 MediaSessionManager (org.schabi.newpipe.player.helper.MediaSessionManager)1 PlayerDataSource (org.schabi.newpipe.player.helper.PlayerDataSource)1 PlayerHelper.getTimeString (org.schabi.newpipe.player.helper.PlayerHelper.getTimeString)1 BasePlayerMediaSession (org.schabi.newpipe.player.playback.BasePlayerMediaSession)1 CustomTrackSelector (org.schabi.newpipe.player.playback.CustomTrackSelector)1