gpt4 book ai didi

android - Exoplayer 视频加载速度

转载 作者:行者123 更新时间:2023-12-05 02:57:07 50 4
gpt4 key购买 nike

我希望在我的项目中实现 exoplayer。我已经成功实现了它,但是视频加载时间很慢。如何在 exoplayer 中实现或实现视频的快速加载?就像抖音一样——立即加载视频并开始播放

最佳答案

试试下面的代码

它使缓冲时间变小,因此您可以更快地加载视频。

//Minimum Video you want to buffer while Playing
private int MIN_BUFFER_DURATION = 2000;
//Max Video you want to buffer during PlayBack
private int MAX_BUFFER_DURATION = 5000;
//Min Video you want to buffer before start Playing it
private int MIN_PLAYBACK_START_BUFFER = 1500;
//Min video You want to buffer when user resumes video
private int MIN_PLAYBACK_RESUME_BUFFER = 2000;

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();

TrackSelector trackSelector = new DefaultTrackSelector();
player = ExoPlayerFactory.newSimpleInstance(this, trackSelector, loadControl);

希望对您有所帮助!

谢谢。

关于android - Exoplayer 视频加载速度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59926822/

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