视频缩略图返回NULL [英] Video thumbnail return null

查看:392
本文介绍了视频缩略图返回NULL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建从存储在我的SD卡中的视频,显示缩略图及其在网格视图名称缩略图。在一个对话框并询问X中的网格视图弹出窗口中选择项目时,Y,右,下位置则粘贴到的主要活动。我得到的视频文件,并试图利用媒体商店也正在检索缩略图为位图创建缩略图,但位为空。在网格视图视频名称显示,我能够选择相应的缩略图,可以给位置也很能设置缩略图的主要活动。问题是位图是空和位图图像不显示(文字争夺显示视频名称)。有什么问题 ?我不出来? PLZ帮我吗?我的code如下。先谢谢了。

 如果(f.isFile()){
      如果(fName.endsWith(MPG)
    || fName.endsWith(MOV)
    || fName.endsWith(WMV)
    || fName.endsWith(RM)
    || fName.endsWith(MP4)){
    tv.setText(FName参数);
    PATH = f.getAbsolutePath();
    的System.out.println(视频文件路径= GT;+路径);
 拇指= ThumbnailUtils.createVideoThumbnail(f.getAbsolutePath(),MediaStore.Video.Thumbnails.MICRO_KIND);
    如果(拇指== NULL)
      {
         / **每当它打印空** /
         的System.out.println(拇指为空);      }
      iv.setImageBitmap(大拇指);


解决方案

ThumbnailUtils.createVideoThumbnail 文件:可能返回null如果视频已损坏或不支持的格式。

在默认情况下,几乎所有支持的格式是MP4和3GP。在这里看到: http://developer.android.com/guide/appendix/media- formats.html 为默认支持的媒体格式完整列表。

I am creating thumbnails from videos stored in my sd card ,displaying thumbnails and its names in grid view. On item selected event of the grid view pop ups a dialog and asking x, y, right, bottom positions then pasting it to the main activity . I got the video files, and tried to create thumbnail using media store also am retrieving thumbnail as bitmap, but the bitmap is null. In the grid view video names are shown and i am able to select the corresponding thumbnail and can give positions also am able set the thumbnail to the main activity. The problem is the bitmap is null and bitmap image not showing(text vie video name shown). What's the problem ? I can't figure it out? Plz help me? My code is given below. thanks in advance.

      if (f.isFile()) {
      if (fName.endsWith(".mpg")
    || fName.endsWith(".mov")
    || fName.endsWith(".wmv")
    || fName.endsWith(".rm")
    || fName.endsWith(".mp4")) {
    tv.setText(fName);
    path = f.getAbsolutePath();
    System.out.println("Video file path=>"+path);


 thumb = ThumbnailUtils.createVideoThumbnail(f.getAbsolutePath(),MediaStore.Video.Thumbnails.MICRO_KIND);


    if(thumb==null)
      {
         /**Every time it printing null**/
         System.out.println("Thumb is null");

      }
      iv.setImageBitmap(thumb);

解决方案

From ThumbnailUtils.createVideoThumbnail documentation: May return null if the video is corrupt or the format is not supported.

By default, almost all supported formats are mp4 and 3gp. See here: http://developer.android.com/guide/appendix/media-formats.html for full list of default-supported media formats.

这篇关于视频缩略图返回NULL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆