gpt4 book ai didi

java - exoplayer 2.11.8版本如何过载控制

转载 作者:行者123 更新时间:2023-12-05 00:13:23 33 4
gpt4 key购买 nike

我正在使用 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();

我想将加载控制传递给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();

在这里,我不知道在哪里传递加载控制。我搜索了他们的 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();

关于java - exoplayer 2.11.8版本如何过载控制,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63632470/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com