Audio_service: How could I load artUri image from assets?

Created on 6 Jun 2020  路  6Comments  路  Source: ryanheise/audio_service

Hi, Please advice, How to load the artUri image from assets. Thank you.
I did Fail :
artUri: 'file://assets/img/photos/w.jpg',

1 backlog enhancement

Most helpful comment

I'll keep this issue open because you filed this as a feature request, and I haven't implemented the feature yet.

All 6 comments

Add these in your pubspec.yaml
assets:
- assets/img/photos/w.jpg

I might consider adding support for a special "asset://" URL scheme in the future.

In the meantime, what you would need to do is copy each asset to a file:

await file.writeAsBytes((await rootBundle.load(assetPath)).buffer.asUint8List());

Then you could use a "file://" URL pointing to where you actually stored the file. Extracting the assets and copying them into files is something you'd only need to do once on your app's first run, or if storing to the cache folder, after each time the user clears the cache.

Thank you very much for your reply.

I'll keep this issue open because you filed this as a feature request, and I haven't implemented the feature yet.

Duplicate of #523

This is my solution, I'm using an image from cache but I'm sure this would work for files in external storage.

Uri artUri = Uri.parse("file:///" + "path/to_file/filename.png");

Was this page helpful?
0 / 5 - 0 ratings