如何获取视频的缩略图

时间:2012-03-12 12:09:11

标签: java android thumbnails

我想获取存储在服务器中的视频的缩略图...并且网格视图将用于显示缩略图...我正在使用android 3.0

以下是我使用过的代码:

String[] videoFileList = {
  "http://129.0.0.213:8080/playback/201203/thumbs/00068.flv_img/0000003.jpg",

};

public class MyThumbnaildapter extends ArrayAdapter<String>{

 public MyThumbnaildapter(Context context, int textViewResourceId,
   String[] objects) {
  super(context, textViewResourceId, objects);
  // TODO Auto-generated constructor stub
 }

 @Override
 public View getView(int position, View convertView, ViewGroup parent) {
  // TODO Auto-generated method stub

  View row = convertView;
  if(row==null){
   LayoutInflater inflater=getLayoutInflater();
   row=inflater.inflate(R.layout.main, parent, false);
  }


  ImageView imageThumbnail = (ImageView)row.findViewById(R.id.gridview);

  Bitmap bmThumbnail;
        bmThumbnail = ThumbnailUtils.createVideoThumbnail(videoFileList[position], Thumbnails.MICRO_KIND);
        imageThumbnail.setImageBitmap(bmThumbnail);

  return row;
 }

}

请帮助我......

1 个答案:

答案 0 :(得分:0)

createVideoThumbnail方法的第一个参数是视频文件路径,就像我从您的查询中正确理解一样,您将文件路径传递给'.jpg'文件。

查看此处的文档http://developer.android.com/reference/android/media/ThumbnailUtils.html#createVideoThumbnail%28java.lang.String,%20int%29

bmThumbnail = ThumbnailUtils.
createVideoThumbnail(THE_PATH_OF_VIDEO_FILE, Thumbnails.MICRO_KIND);