问题
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