Skip to content

Sample app to demonstrate Picasso pull request 657 "Support retrieval of specific frames from MediaStore videos"

Notifications You must be signed in to change notification settings

jacobtabak/Picasso-Video-Frame-Loader

Repository files navigation

Pull Request

View the original pull request here

Demo

Gif of demo app

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). The end result turned out quite nicely, you can see a demonstration here (youtube):

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.

About

Sample app to demonstrate Picasso pull request 657 "Support retrieval of specific frames from MediaStore videos"

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published