sc4v3ng3r / flutter_audio_query

Flutter Audio Query Plugin
https://pub.dev/packages/flutter_audio_query
MIT License
52 stars 48 forks source link

Album Art returns null on Android 10 #21

Closed athul-ain closed 3 years ago

shayan4shayan commented 4 years ago

album_art has been deprecated starting from api 29 and have to call `contentResolver. loadThumbnail and get the bitmap. the problem is, there is no way to send bitmap on method channel and get it in dart code.

solution is, saving every album art in cache and send file path of images from cache to dart code.

I've managed to do so but it requires an initialization process that takes long.

https://github.com/shayan4shayan/flutter_audio_query/commit/f9e2f46934a01d32c0df35dc539360b0f037f5c6

there is a way to fix this. saving all of album arts in a single background thread and managing multiple images there.

but I don't know which one is better.

athul-ain commented 4 years ago

I have Tried your Tree But got this error. Can you help in implementing this?

C:\PathtoPackage\flutter_audio_query-a10-fix\android\src\main\java\boaventura\com\devel\br\flutteraudioquery\loaders\SongLoader.java:15: error: package boaventura.com.devel.br.flutteraudioquery.loaders.cache does not exist import boaventura.com.devel.br.flutteraudioquery.loaders.cache.AlbumArtCache;

shayan4shayan commented 4 years ago

I have Tried your Tree But got this error. Can you help in implementing this?

C:\PathtoPackage\flutter_audio_query-a10-fix\android\src\main\java\boaventura\com\devel\br\flutteraudioquery\loaders\SongLoader.java:15: error: package boaventura.com.devel.br.flutteraudioquery.loaders.cache does not exist import boaventura.com.devel.br.flutteraudioquery.loaders.cache.AlbumArtCache;

Sorry, I've missed one of my commits and it didn't pushed to git.

https://github.com/shayan4shayan/flutter_audio_query/commit/c83f8ee79249d8e1f6da8a1cb69e9a7ffca42b7b

athul-ain commented 4 years ago

Thanks

norsparyt commented 4 years ago

hey, i tried using it (after your last commit) ,and i'm getting a "no such path or directory" when trying to display the images using Image.file(File(path)) ( i'm able to get the paths

Could you share the code to display the images ?

athul-ain commented 4 years ago

hey, i tried using it (after your last commit) ,and i'm getting a "no such path or directory" when trying to display the images using Image.file(File(path)) ( i'm able to get the paths

Could you share the code to display the images ?

Try this as your Path "getTemporaryDirectory/albums/albumId.jpg" Note: getTemporaryDirectory from PathProvider, Use the appropriate albumId

shayan4shayan commented 4 years ago

hey, i tried using it (after your last commit) ,and i'm getting a "no such path or directory" when trying to display the images using Image.file(File(path)) ( i'm able to get the paths Could you share the code to display the images ?

Try this as your Path "getTemporaryDirectory/albums/albumId.jpg" Note: getTemporaryDirectory from PathProvider, Use the appropriate albumId

well that's the bug in first launch you have to get all the albums and wait till all images saves into the disk.

in the last change of android you cannot access album images using file path and you have to use URI that is not possible in flutter. so I had to save all the album images in cache folder and use path of images in there. but saving all the images in cache folder in first launch takes time and you must load albums in the first launch to trigger the save action.

norsparyt commented 4 years ago

hey, i tried using it (after your last commit) ,and i'm getting a "no such path or directory" when trying to display the images using Image.file(File(path)) ( i'm able to get the paths Could you share the code to display the images ?

Try this as your Path "getTemporaryDirectory/albums/albumId.jpg" Note: getTemporaryDirectory from PathProvider, Use the appropriate albumId

Tried PathProvider , same error. Have you been able to show the images in a device?

athul-ain commented 4 years ago

hey, i tried using it (after your last commit) ,and i'm getting a "no such path or directory" when trying to display the images using Image.file(File(path)) ( i'm able to get the paths Could you share the code to display the images ?

Try this as your Path "getTemporaryDirectory/albums/albumId.jpg" Note: getTemporaryDirectory from PathProvider, Use the appropriate albumId

Tried PathProvider , same error. Have you been able to show the images in a device?

Yes, but the images was not shown for songs on Non-Android10 devices. It works well for Albums and Artists.

pedrolemoz commented 4 years ago

I had the same issue here, but @shayan4shayan fork's is working, but a bit slowly. Anyway, at least, it work. @sc4v3ng3r Please merge PR to this package!

shayan4shayan commented 4 years ago

I had the same issue here, but @shayan4shayan fork's is working, but a bit slowly. Anyway, at least, it work. @sc4v3ng3r Please merge PR to this package!

seems there is some problems in android 9 or bellow I must fix them first,

pedrolemoz commented 4 years ago

@shayan4shayan Have you tried to convert the image to base64 (it will be a string), and then, pass it over method channel to Dart? I think it's a clever solution, better than caching files. Obviously, it will require some workaround in the package (returning the image instead a path), but may be a solution. What do you think?

shayan4shayan commented 4 years ago

@shayan4shayan Have you tried to convert the image to base64 (it will be a string), and then, pass it over method channel to Dart? I think it's a clever solution, better than caching files. Obviously, it will require some workaround in the package (returning the image instead a path), but may be a solution. What do you think?

Base64 is a good solution but it won't decrease the size of image and in the query of albums all of the data stored as album images must be sent over method channel and also it requires reading all of images in every query and it will take so long.

shayan4shayan commented 3 years ago

@pedrolemoz @athul-ain song images for non-android 10 devices has been fixed.

mahadydev commented 3 years ago

any hope for android 10? still getting null path for the image art

shayan4shayan commented 3 years ago

any hope for android 10? still getting null path for the image art

I released a quick fix, get albums first. then song album path will be set. I'm still thinking about a better way to fix this issue. but it won't be perfect unless flutter gives ability to load image with URI.

mahadydev commented 3 years ago

hi , did you pushed the quick fix on pub.dev ?

shayan4shayan commented 3 years ago

hi , did you pushed the quick fix on pub.dev ?

the main developer seems stopped developing this package and your answer is no.

I'll create a new package as soon as I find a proper fix for this problem.

sc4v3ng3r commented 3 years ago

For now solved with #36 I am closing it.