1

Okay this might be a stupid one but kindly pardon me because I'm new to Android. I'm working on an App in which I want to display video thumbnails using remote URL's like:

Video URL: http://173.193.24.66/~kanz/video/flv/9.flv

.JPG URL: http://173.193.24.66/~kanz/video/Images/9.jpg

I have got both the video URL's and Image File URL's that I want to display on thumbnails stored on SQL database. The only thing is I don't know how to put them in List view inside a ScrollView. I tried searching on the Internet but they all seem to give tutorials on how to display video thumbnails from sd card path. I want to use any of these URL's to display video thumbnails. I heard about API's but I can't use Youtube API since Youtube is banned in my country. If anyone knows any useful API or any other hack around, let me know. It would be highly appreciated. I'm using Gingerbread.

Abdus Sami Khan
  • 267
  • 2
  • 8
  • 20

3 Answers3

2

Add these lines to your Module:app gradle:

dependencies {
  implementation 'com.github.bumptech.glide:glide:4.9.0'
  annotationProcessor 'com.github.bumptech.glide:compiler:4.9.0'
}
// pass video url into .load() method
  Glide.with(context)
                .asBitmap()
                .load(/*Video Url*/)
                .into(/*Name of Imageview*/);
Bhavik Nathani
  • 470
  • 5
  • 13
1

Those tutorials are correct but you're missing a step. You need to download these images to the device first using the URL. Then you can set them up to be viewed in a listview.

See how to do this in these threads:

There is a popular open source library that handles downloading and caching of images automatically. Check it out:

https://github.com/koush/UrlImageViewHelper

Community
  • 1
  • 1
Anup Cowkur
  • 20,443
  • 6
  • 51
  • 84
1

Listview has its own scroll. So do not put listview inside a scroll view.

Use a custom listview to display the thumbnail.

Get your urls form the database.

http://www.androidhive.info/2012/02/android-custom-listview-with-image-and-text/

http://www.youtube.com/watch?v=wDBM6wVEO70. The talk is about listview and performance.

Use a viewholder.http://developer.android.com/training/improving-layouts/smooth-scrolling.html.

If you are displaying lot of images in listview consider using one of the below libraries.

1.Universal Image loader. https://github.com/nostra13/Android-Universal-Image-Loader.

2.Lazy List. https://github.com/thest1/LazyList.

Both use caching.

For univarsal Image Loader

In your adapter constructor

  File cacheDir = StorageUtils.getOwnCacheDirectory(a, "UniversalImageLoader/Cache");
  imageLoader = ImageLoader.getInstance();

   ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(a)
          // You can pass your own memory cache implementation
         .discCache(new UnlimitedDiscCache(cacheDir)) // You can pass your own disc cache implementation
         .discCacheFileNameGenerator(new HashCodeFileNameGenerator())
         .enableLogging()
         .build();
 // Initialize ImageLoader with created configuration. Do it once.
 imageLoader.init(config);
 options = new DisplayImageOptions.Builder()
.showStubImage(R.drawable.stub_id)//dummy image
.cacheInMemory()
.cacheOnDisc()
.displayer(new RoundedBitmapDisplayer(20))
.build();

In your getview()

  ImageView image=(ImageView)vi.findViewById(R.id.imageview); 
  imageLoader.displayImage(imageurl, image,options);
Raghunandan
  • 132,755
  • 26
  • 225
  • 256