Fetch YouTube streams in 10 MB ranges to stop stalls #24
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/playback-stall"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
On first play, video froze after ~7 s and only resumed much later. YouTube throttles a single open-ended download of a googlevideo stream (~1 MB/s after an initial burst), while bounded range requests (<=10 MB) are served at full speed (~90 MB/s measured on the same URL). ExoPlayer's progressive source opened one unbounded request per stream, so the 1080p video starved once the burst ran out.
Fix
ChunkedDataSourcewraps the OkHttp data source and reads each stream as consecutive 10 MB range requests (usesclenfrom the URL to report the total length).PlaybackController.buildSourceuses it for both video and audio.clen.Verified
Emulator (Android TV API 36), 1080p avc1 + opus: before, playback stalled at 7.3 s for 21 s; after, 90 s of continuous playback with no rebuffering, and restart (seek to 0) works. Not yet tested on the FPT box.
Vi: Sửa lỗi video bị khựng sau vài giây đầu khi phát bài