开发者

Android: Is it possible to display very fast video thumbnails?

开发者 https://www.devze.com 2023-01-29 00:25 出处:网络
I created video player list with video thumbnail. but scorll display time is very slow.. how can I display fast video thumnail? The list of video is8 lines.. and source ->

I created video player list with video thumbnail. but scorll display time is very slow.. how can I display fast video thumnail? The list of video is 8 lines.. and source ->

ImageView imageView = null;
Bitmap bm = null;

bindView(View view, int iViewType, Context context,Cursor cursor, boolean bExpand) 
{
bm= MediaStore.Video.Thumbnails.getThumbnail(vmcontext.getContentResolver(),index, MediaStore.Video.Thumbnails.MINI_KIND, null);
开发者_如何学CimageView.setImageBitmap(bm);
}

I can display video thumbnail. but list display or scroll display is very slow.


The simple way is to make your own content cacher.

For example:

ImageView imageView = null; Bitmap bm = null;
HashMap<String, ImageView> cacher = new HashMap<String, ImageView>();

bindView(View view, int iViewType, Context context,Cursor cursor, boolean bExpand) 
{
   if (cacher.containsKey("id"))
   {
     imageView.setImageBitmap(cacher.get("id"));
   }
   else
   {
     bm= MediaStore.Video.Thumbnails.getThumbnail(vmcontext.getContentResolver(),index, MediaStore.Video.Thumbnails.MINI_KIND, null);
     cacher.put("id", bm);
     imageView.setImageBitmap(bm); 
   }
}

This is good if your thumbnail's scroll view display many times the same thumbnails when the user scroll up and down. At the end all cached content will do smoothed scrolling.

Moreover, if possible, you could do a prefetch of thumbnails, populating the cacher, using an AsyncTask before the grid of thumbs is displayed.

Remember to limit and flush the cacher to not fill the memory.

Tobia

0

精彩评论

暂无评论...
验证码 换一张
取 消