Exoplayer video loading speed

江枫思渺然 提交于 2020-12-13 04:36:32

问题


I'm looking to implement exoplayer in my project. I have successfully implemented it, but the loading time of video is slow. how to implement or to achieve speed loading of the video in exoplayer? just like tiktok does it - immediately loads the video and starts playing


回答1:


Try below code

It's make buffer time small So,you can load video more speedily.

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

I hope this can help You!

Thank You.



来源:https://stackoverflow.com/questions/59926822/exoplayer-video-loading-speed

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!