首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > 移动开发 >

应用 MediaMetadataRetriever类获取视频缩略图

2012-11-21 
使用 MediaMetadataRetriever类获取视频缩略图 使用代码private Bitmap getThumbnail(Context paramContex

使用 MediaMetadataRetriever类获取视频缩略图

 

使用代码

private Bitmap getThumbnail(Context paramContext, long paramLong, Uri paramUri)
    {
      MediaMetadataRetriever localMediaMetadataRetriever = new MediaMetadataRetriever();
      Bitmap localBitmap1;
      try
      {
        localMediaMetadataRetriever.setDataSource(paramContext, paramUri);//获取图像前必须先设置dataSource
     
        Bitmap localBitmap2 = localMediaMetadataRetriever.getFrameAtTime(1000L * paramLong);//获取指定时间视频文件图像
        localBitmap1 = localBitmap2;
        if(localBitmap1==null){
         localBitmap1=BitmapFactory.decodeResource(paramContext.getResources(), R.drawable.ic_video_default);
        }
        return localBitmap1;
      }
      catch (RuntimeException localRuntimeException)
     
      {
        Log.d("SecVideoWidgetProvider", "getThumbnail localRuntimeException");
        return null ;
      }
 
    }

热点排行