-
-
Notifications
You must be signed in to change notification settings - Fork 484
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add optional cache key for MediaItem art #1001
Comments
If the URls are not stable, then your approach sounds a bit fragile, since you can't predict whether audio_service will resolve the URLs before they expire. You would be better off doing this in a more controlled manner where you obtain your perishable URLs, then preemptively download them to local files in your app's local store, and then simply pass Aside from that, I'm not comfortable with adding a field to |
The URLs don't expire, they're token based and can change because the salt used to generate them changes, or because a user changes their password, etc. I don't want to re-download the image every time in these cases and I'd like to use the cache managers I'm already using with these custom cache keys. I also don't really want to implement my own image pre-caching system outside the cache manager as it does a pretty good job of it already. If adding a field to MediaItem isn't a good way to do it, an alternative approach I considered was to have an additional param on |
I suppose that could work. There is also "maybe" a possibility to implement a custom cache manager (although I don't have the API in front of me right now to confirm that). |
That's what I'm already doing now actually, although not heavily, so I can customize the amount of time things are kept for and a few other things, and I pass that cache manager to audio_service and use it in my app to display the same images from cache with cached_network_image. There are potentially a lot of images I'm putting on a user's device so I want to avoid caching them more than once. I'm not sure it's possible to customize the cache key resolution in the cache manager without really reworking how it's built, since it allow you to pass a cache key on your own with the URI. Other packages like cached_network_image that also rely on flutter_cache_manager allow passing the cache key when you pass the URI so I figure it'd be reasonable to allow some way to do it here too. |
Understood. I suppose that the I don't want to rush API design decisions, so perhaps you can also think on these options and see what you feel is going to be best taking into account all of the considerations. |
Cool, I have another branch with the |
Been testing that PR in my app, and it works flawlessly. |
Feature proposal
I would like to be able to specify an optional
cacheKey
when defining aMediaItem
, so that when art for that item is retrieved from the cache manager I can control what key is used.Motivating use case(s)
My app uses custom cache keys for images because the URLs used to get them are not guaranteed to be stable.
I can provide a PR if this works for you, as I already have a working branch with this feature in my fork here: https://github.com/austinried/audio_service/tree/features/mediaitem-artcachekey
The text was updated successfully, but these errors were encountered: