square/picasso — pull request #657 by jacobtabak (2014-09-12 19:23:15+00:00)
Title: Support retrieval of specific frames from MediaStore videos

**Motivation**

Picasso supports loading of MediaStore video thumbnails, however the thumbnail generated by Android is pulled from the middle of the video. For this project, we needed to load the first frame of a video that automatically starts when the user scrolls to the center of the screen, to avoid [this (youtube)](https://www.youtube.com/watch?v=OjrLCzgi0s8). The end result turned out quite nicely, you can see a demonstration [here (youtube)](https://www.youtube.com/watch?v=O1paNAL7XnM):

**API**

Uri uri = myVideoUri.buildUpon().appendQueryParameter("t", "0").build();
Picasso.with(context).load(uri).into(imageview)

This is still up in the air. I had originally suggested `load(Uri uri, long offset)`, but it almost certainly doesn't make sense to add a new method signature for such an obscure feature. So I settled on the current implementation, which follows YouTube's convention of appending `?t=[position]` to the end of a uri, for example: `https://www.youtube.com/watch?v=wtLJPvx7-ys#t=3945`

YouTube's time query parameter is in seconds, but since the underlying API that this change uses (`android.media.MediaMetadataRetriever`) accepts the time position in microseconds, my initial implementation does as well, but that's definitely not set in stone.

**Tests**

In this PR, I upgraded Robolectric from 2.2 to 2.3. 2.2 did not have a shadow MediaMetadataRetriever implementation. However, the implementation in 2.3 was incomplete so I ended up writing my own shadow MediaMetadataRetriever (which I will be submitting as a PR to them). All the tests still pass, but this PR doesn't require Robolectric 2.3 to so we can revert to 2.2 if necessary.