Exoplayer 视频加载速度

Exoplayer video loading speed

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

试试下面的代码

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

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

希望对您有所帮助!

谢谢。