Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ExoPlayer initialize player deprecated

I'm currently working with the latest ExoPlayer update and I'm getting calls that it is deprecated, could someone help me?

private fun initializePlayer () {

    if (simpleExoPlayer == null) {
        val trackSelector = DefaultTrackSelector(this)
        val loadControl = DefaultLoadControl()
        simpleExoPlayer = E̶x̶o̶P̶l̶a̶y̶e̶r̶F̶a̶c̶t̶o̶r̶y̶.̶n̶e̶w̶S̶i̶m̶p̶l̶e̶I̶n̶s̶t̶a̶n̶c̶e̶(this, trackSelector, loadControl)
    }
}
like image 500
Kevin Paul Montealegre Melo Avatar asked Jan 25 '23 19:01

Kevin Paul Montealegre Melo


1 Answers

Setting Up Exoplayer version(2.11.8) :
Sep 2020 Update:

//Setting Up Exoplayer
private void SetupPlayer(){
        SimpleExoPlayer simpleExoPlayer;
// Create a data source factory.
        dataSourceFactory =
                new DefaultHttpDataSourceFactory(Util.getUserAgent(this
                        , getApplicationInfo().loadLabel(getPackageManager()).toString()));
// Passing Load Control
        loadControl = new DefaultLoadControl.Builder()
                .setBufferDurationsMs(25000, 50000, 1500, 2000).createDefaultLoadControl();

        @DefaultRenderersFactory.ExtensionRendererMode int extensionRendererMode = DefaultRenderersFactory.EXTENSION_RENDERER_MODE_PREFER;

        renderersFactory = new DefaultRenderersFactory(this) .setExtensionRendererMode(extensionRendererMode);

// Create a progressive media source pointing to a stream uri.
         mediaSource = new ProgressiveMediaSource.Factory(dataSourceFactory)
                .createMediaSource(Uri.parse(url_to_stream));
// Create a player instance.
        simpleExoPlayer =  new SimpleExoPlayer.Builder(this,renderersFactory).setLoadControl(loadControl).build();
// Prepare the player with the media source.
        simpleExoPlayer.prepare(mediaSource, true, true);
}
like image 81
Smack Alpha Avatar answered Feb 04 '23 09:02

Smack Alpha