exoplayer 2.11.8版本如何过载控制

how to pass load control in exoplayer 2.11.8 version

我正在使用 exoplayer 2.11.8 版本。在这个版本中,他们改变了很多方法。通过搜索他们的文档,我构建了 Exoplayer.

代码如下:

DataSource.Factory dataSourceFactory =
                new DefaultHttpDataSourceFactory(Util.getUserAgent(this
                        , getApplicationInfo().loadLabel(getPackageManager()).toString()));
       
LoadControl loadControl = new DefaultLoadControl.Builder()
                .setAllocator(new DefaultAllocator(true, 16))
                .setBufferDurationsMs(MIN_BUFFER_DURATION,
                        MAX_BUFFER_DURATION,
                        MIN_PLAYBACK_START_BUFFER,
                        MIN_PLAYBACK_RESUME_BUFFER)
                .setTargetBufferBytes(-1)
                .setPrioritizeTimeOverSizeThresholds(true).createDefaultLoadControl();
// Create a progressive media source pointing to a stream uri.
MediaSource mediaSource = new ProgressiveMediaSource.Factory(dataSourceFactory)
                .createMediaSource(Uri.parse(audio_url));
// Create a player instance.
simpleExoPlayer =  new SimpleExoPlayer.Builder(this).build();

我想把 load control 传给 exoplayer。在旧版本中,Load control 像下面这样传递,

TrackSelector trackSelector = new DefaultTrackSelector();

DefaultLoadControl loadControl = new DefaultLoadControl.Builder().setBufferDurationsMs(32*1024, 64*1024, 1024, 1024).createDefaultLoadControl();
player = ExoPlayerFactory.newSimpleInstance(this, trackSelector, loadControl);

在较新的版本中,他们更改了创建 exoplayer 实例的代码,如下所示

simpleExoPlayer =  new SimpleExoPlayer.Builder(this).build();

在这里,我不知道把load control传到哪里去。我搜索了他们的 exoplayer 文档。但是没有传load control的例子。 请帮助我并提供一些解决方案以将 load control 传递给 exoplayer

检查以下代码。

DefaultRenderersFactory renderersFactory;
    
DefaultLoadControl loadControl = new DefaultLoadControl.Builder().setBufferDurationsMs(25000, 50000, 1500, 2000).build();
                        
@DefaultRenderersFactory.ExtensionRendererMode int extensionRendererMode = DefaultRenderersFactory.EXTENSION_RENDERER_MODE_PREFER;

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

player = new SimpleExoPlayer.Builder(context, renderersFactory)
                                    .setTrackSelector(trackSelector)
                                    .setLoadControl(loadControl)
                                    .build();