5

I use universal image loader in girdview. Some of videos are fine to change image and some are not work and give error like that,

03-17 12:49:52.287: D/skia(21755): --- SkImageDecoder::Factory returned null
03-17 12:49:52.287: E/ImageLoader(21755): Image can't be decoded [file:////storage/sdcard0/Movies/Naruto Episodes 55.mp4_270x270]

Here is my code in main class.

     DisplayImageOptions defaultOptions = new DisplayImageOptions.Builder()
            .cacheOnDisc(true).cacheInMemory(true)
            .imageScaleType(ImageScaleType.EXACTLY)
            .displayer(new FadeInBitmapDisplayer(300)).build();

    ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(
            getApplicationContext())
            .defaultDisplayImageOptions(defaultOptions)
            .memoryCache(new WeakMemoryCache())
            .discCacheSize(100 * 1024 * 1024).build();

    ImageLoader.getInstance().init(config);

Here is code in adpater,

    String url = "/storage/sdcard0/Movies/Naruto Episodes 55.mp4";


    ImageLoader imageLoader = ImageLoader.getInstance();
    DisplayImageOptions options = new DisplayImageOptions.Builder().cacheInMemory(true)
                    .cacheOnDisc(true).resetViewBeforeLoading(true)
                    .showImageForEmptyUri(R.drawable.x_document_icon)
                    .showImageOnFail(R.drawable.x_document_icon)
                    .showImageOnLoading(R.drawable.x_document_icon).build();

    //initialize image view


    //download and display image from url
    imageLoader.displayImage("file:///"+url, img_btn, options);

The following code work fine but it take some time.

   Bitmap bitmap = ThumbnailUtils.createVideoThumbnail(url, 0);
   img_btn.setImageBitmap(bitmap);
Halo
  • 729
  • 1
  • 8
  • 18
  • 1
    Image you are trying to decode or load having invalid extension. `file:////storage/sdcard0/Movies/Naruto Episodes 55.mp4_270x270` debug and check what exact url UIL fetching. – SilentKiller Mar 17 '15 at 04:29

1 Answers1

0

Your file name contains spaces there is an issue posted in Github. Based on the comments this solution works though I have not tried it yet:

if (file.exists()) {
    final String uri = Uri.fromFile(file).toString();
    final String decoded = Uri.decode(uri);
    ImageLoader.getInstance().displayImage(decoded, imageView);
}

As per your comment this should work:

String url = "/storage/sdcard0/Movies/Naruto Episodes 55.mp4";
imageLoader.displayImage("file:///"+Uri.decode(url), img_btn, options);
Illegal Argument
  • 10,090
  • 2
  • 44
  • 61