square / picasso

A powerful image downloading and caching library for Android
https://square.github.io/picasso/
Apache License 2.0
18.7k stars 3.97k forks source link

Document the use of MediaStoreRequestHandler #817

Open commonsguy opened 9 years ago

commonsguy commented 9 years ago

Of note, what Uri do we hand to Picasso, and what is the canonical way that Square is expecting us to create or retrieve that Uri? For example, ContentUris.withAppendedId(MediaStore.Video.Media.EXTERNAL_CONTENT_URI, videoId), where videoId is the MediaStore.Video.Media._ID value retrieved by a query on MediaStore.Video.Media.EXTERNAL_CONTENT_URI, does not seem to work with Picasso 2.4.0. Picasso never replaces the placeholder, and I get SkImageDecoder::Factory returned null messages corresponding with each request.

However, this may warrant more documentation, particularly for developers porting over from other solutions (e.g., explaining how Picasso handles MICRO, MINI thumbnail kinds).

Thanks!

jacobtabak commented 9 years ago

I'm always in favor of more documentation... but aside from that, are you able to view video thumbnails for these same videos in the Photos (or Gallery) app? Picasso uses the MediaStore.Video.Thumbnails.getThumbnail() API to load thumbnails for videos. The documentation for [getThumbnail()](http://developer.android.com/reference/android/provider/MediaStore.Video.Thumbnails.html#getThumbnail%28android.content.ContentResolver, long, int, android.graphics.BitmapFactory.Options%29) says

Returns A Bitmap instance. It could be null if the original image associated with origId doesn't exist or memory is not enough.

Are you able to get a bitmap thumbnail for your videos using that API directly?

It's a bit foggy, but I'm fairly certain I have successfully used Picasso to load video thumbnails in 2.4.0, but instead have opted to use my own custom RequestHandler that uses MediaMetaDataRetriever.getFrameAtTime() so we can get full-resolution frames, rather than thumbnails constrained to 512x384px.

commonsguy commented 9 years ago

Are you able to get a bitmap thumbnail for your videos using that API directly?

Yes. I wrote this sample app a year and change ago. It uses SmartImageView and getThumbnail(), as Picasso had no extensible RequestHandler system at the time (short of modifying the library proper). It works perfectly fine on the same device with the same videos.

I am creating a variation on this sample that uses leanback-17 for rendering the roster of videos. I was looking to cut over to Picasso as a replacement for SmartImageView.

but instead have opted to use my own custom RequestHandler that uses MediaMetaDataRetriever.getFrameAtTime() so we can get full-resolution frames, rather than thumbnails constrained to 512x384px.

In my case, thumbnails are fine. That being said, your workaround may prove necessary in my case as well -- thanks!