Demo app, DownloadTracker and PlayerActivity class from the demoHow to attach extra meta info like id, artist name, artwork url, title etc while using DownloadManager from offline package to cache media files and retrieve it later with it's status?
I am able to cache the media files but not able to attach extra info with the downloaded item so that I can later query it and display it in another screen where it can be played offline
I checked out DownloadTracker class from the demo app but it does not provide required info on how to get it done.
Create a ContentMetadataMutations instance, set custom key/value pairs (using ContentMetadata.KEY_CUSTOM_PREFIX to avoid colliding with ExoPlayer's metadata keys) then apply those mutations via Cache.applyContentMetadataMutations on the cache that you're passing to DownloadManager. Metadata can be retrieved via Cache.getContentMetadata. @ojw28 Please correct this if I've missed something. Thanks.
I don't think Cache is the right level of API to be using for this.
I think you should be using DownloadRequest.data. When you create a DownloadRequest to download an item, you can serialize whatever custom data you want into that field, and it will be persisted along with information about the download. Whenever you query the downloads, you can retrieve the data from Download.request.data. Serializing and de-serializing the responsibility of the app developer.
Most helpful comment
I don't think
Cacheis the right level of API to be using for this.I think you should be using
DownloadRequest.data. When you create aDownloadRequestto download an item, you can serialize whatever custom data you want into that field, and it will be persisted along with information about the download. Whenever you query the downloads, you can retrieve the data fromDownload.request.data. Serializing and de-serializing the responsibility of the app developer.