Check out my personal blogsVisit maxrave.dev
SimpMusicSimpMusic Docs
For Developers

Downloads & cache

The two-cache model, lazy URL resolution, expiry handling, and download states.

Downloading and streaming share one pipeline but two separate stores, which is why the Storage screen can clear them independently.

Two caches

CacheHoldsCleared by
playerCacheWhatever streamed through the playerPlayer Cache
downloadCacheTracks explicitly downloadedDownloaded Cache

Only playerCache is subject to the Limit Player Cache ceiling (100 MB – 8 GB, or unlimited). Downloads are never evicted by that limit — otherwise "downloaded for offline" would not survive a long listening session.

Lazy URL resolution

Downloads go through a ResolvingDataSource wrapping a CacheDataSource. For each request:

Check both caches. If the range is already cached, the request is served locally and no network call happens.

Otherwise resolve a fresh stream URL through StreamRepository.

If a stored format still has a URL and hasn't expired, reuse it — but verify it doesn't return 403 first.

On expiry or 403, fetch a new stream URL and retry with it.

That 403 check matters: YouTube stream URLs are time-limited and tied to a session, so a URL cached yesterday will often still look valid while returning 403 on use.

Video downloads

Video and audio arrive as separate streams. Media IDs are prefixed (MERGING_DATA_TYPE.VIDEO) so the resolver knows which stream to fetch, and the two are merged into one file.

Download states

DownloadState has four values, not three:

ConstantValueMeaning
STATE_NOT_DOWNLOADED0Nothing stored
STATE_PREPARING1Queued, resolving before bytes move
STATE_DOWNLOADING2Transfer in progress
STATE_DOWNLOADED3Complete

The preparing state is the one users notice as "nothing is happening yet" — it covers URL resolution before any bytes are transferred.

Community

Get involved in our community. Everyone is welcome!

SimpMusic is sponsored by:

Get free $200 credit over 60 days on DigitalOcean: GET NOW

Crowdin and Sentry both have a free enterprise plan for Open-source projects. Follow the URLs:

Check out the Vercel open-source program

SimpMusic app is FOSS and under GPL-3.0 license.

© 2023-2026 SimpMusic - @maxrave-dev

We are not affiliated with or endorsed by Google, YouTube, Spotify, or any other third-party brands or applications.