On Demand read-ahead: played while it downloads
Built 2026-10-11.
A provider's movie or episode used to be read straight off the provider by VLC, three seconds ahead of the picture. A slow patch at the provider's end longer than that showed as a stutter. Now the screen downloads the file as fast as the provider sends it and VLC reads it from this device, so a few minutes in the download is far ahead of the picture.
It's a buffer for the title playing, not a kept copy: it's deleted when the title stops. Saving a title into Plex is the relay's job (vod-relay.md, phase 2), not built yet.
Planned 2026-10-17: the relay's Mac does this fetching for every screen, with what's here as the fallback: vod-fetch.md.
What's read ahead #
- Every provider file, MKV, AVI and MP4 alike. VLC plays all of a provider's files (AVPlayer was left on "opening" by some MP4s, with no way to tell it had stuck). AVPlayer is only used for Plex's playlists.
- Not Plex. It's on the home network, and what it transcodes arrives as a playlist, not a file.
- Not a provider that won't send part of a file, and not when the device has too little room. Those play straight off the provider as before, with VLC reading twenty seconds ahead where it used to read three, which makes the start and each skip slower. The Manager's Errors pane says so when it happens ("… isn't read ahead", with why, and how much room there was), and the Manager's own player says "VLC · read ahead" when it is.
How it works #
The player is handed an address on this device (http://127.0.0.1:<port>/<a random name>.mkv) in place of the provider's, which has the login in it and
never leaves the app.
- One download. A login may allow a single stream, so there is never a second request to the provider: when the player skips past what has arrived, the download is stopped and started again from there. It asks at the address the provider's first answer led to, so a panel that starts a session per request isn't asked at the door each time.
- What has arrived is kept in runs. A skip forward starts a new run and leaves the old one, so skipping back is instant.
- Skips. A skip within what has arrived is instant. One past it waits for the download to start there, as a skip always did.
- Room. At most 8 GB, and never the device's last 2 GB. A file bigger than that is held as a window around the picture: the oldest part behind it is deleted as the download goes on. With under about 2.1 GB free there's no read-ahead at all.
- The provider goes quiet. The download tries again, more slowly each time: eight more tries, which is half a minute when the provider turns them away and a couple of minutes when it doesn't answer at all. If it's still gone, the title plays what was held and then says "Lost the connection to where it's kept"; your place is kept.
- The app is put away mid-title. The system takes the server's port; it's opened again on the same one, since that's the address VLC was given.
- Where it's kept. The app's caches, in
ReadAhead/. Deleted when the title stops, and swept at the next title if the app was quit mid-film.
Buffer Ahead #
For a title that still stutters (the provider slower than the film, or a slow patch in the first minute, before the download has got ahead):
- Offered when it stutters. When the picture stops twice within a minute and a half, or once for five seconds, each time because the download had nothing more to give, a line appears for twenty seconds: SLOW CONNECTION · SELECT, THEN BUFFER AHEAD. Select pauses and opens the menu on that row. A picture that stops with plenty downloaded is VLC struggling with the file; that's never offered for, since more downloading wouldn't help.
- In the paused menu, any time. BUFFER AHEAD, with how much is ahead now. It shows only for a title being read ahead, while there's more to come.
- What it does. Holds the picture until three minutes are downloaded ahead (or the rest of the title), then plays by itself. The bar says how far it has got; Select or Play/Pause plays sooner.
- The bar shows how far the download has got, as a paler stretch past the picture's place.
"Ahead" is counted from where VLC has read to, which is itself a few seconds past the picture, so there's always a little more than it says.
The loading bar #
The loading screen (TV, Mac and the Manager's player) says what it's waiting on, and for a title read ahead it has a bar:
- ASKING THE PROVIDER, then DOWNLOADING with a bar for a title read ahead: bytes held past the player's place, against about 24 MB (what VLC reads before it shows a picture). It only moves forward, since the player's read of a file's index at the end moves where "ahead" is counted from, and stops at 95% until there's a picture.
- OPENING, with no bar, for everything else (AVPlayer, Plex, a file the provider won't send part of): nothing is measurable there, so the bar isn't faked.
The 24 MB is a guess from VLC's own read-ahead, not measured on the Apple TV.
Where it is in the code #
ReadAhead,ReadAheadMap,SlowWatch(RetroLineup): what's held, where the download goes next, what's let go, the player's requests and when to offer. Plain values, tested inReadAheadTests.ReadAheadSession.swift(Shared): the download, the folder of chunk files, and the server on the loopback.OnDemandCatalog.stream(for:)hands the player the local address;OnDemandPlaybackandOnDemandControlshave the offer, the menu row and the bar.
Phin Tech docs
Rabbit Ears Manager in the store →