英文:
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();
// 创建一个指向流媒体 URI 的渐进式媒体源。
MediaSource mediaSource = new ProgressiveMediaSource.Factory(dataSourceFactory)
.createMediaSource(Uri.parse(audio_url));
// 创建播放器实例。
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
的解决方案。
英文:
I am using exoplayer 2.11.8
version. In this version, they have changed the lot of methods. By Searching their docs, I build the Exoplayer
.
Here's the Code:
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();
I want to pass the load control
to exoplayer. In older versions, Load control
was passed like below,
TrackSelector trackSelector = new DefaultTrackSelector();
DefaultLoadControl loadControl = new DefaultLoadControl.Builder().setBufferDurationsMs(32*1024, 64*1024, 1024, 1024).createDefaultLoadControl();
player = ExoPlayerFactory.newSimpleInstance(this, trackSelector, loadControl);
In newer version, they have changed the code for creating exoplayer instance which is shown below
simpleExoPlayer = new SimpleExoPlayer.Builder(this).build();
In here, i don't know where to pass the load control
. I searched their exoplayer
docs. But there is no example for passing load control
.
Please help me and provide some solution to pass load control
to exoplayer
答案1
得分: 6
请检查以下代码。
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();
英文:
Check following code.
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();
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论