1

I'm building a video player. I've thousands of video files stored in both internal and external storage. So my video listview is very long and take time to load. my listview contains an imageview and a text view. I can cache the thumbnails, but don't know what to do with the list.. any idea???

Sujith S Manjavana
  • 1,417
  • 6
  • 33
  • 60

4 Answers4

1

You should not load all the contents at the same time. use a LRUcache to store a few thumbnails and add/delete one element each time you need a new image. Simply show a progress dialog before loading success. Refer this for usage of LruCache.

You can refresh the image data in getView method

suitianshi
  • 3,300
  • 1
  • 17
  • 34
  • Thank you, But I have successfully cached the thumbnails. I'm looking for a way to cache the list(the file paths) instead of scanning the sdcard all time. can you post the code.. – Sujith S Manjavana Jan 16 '14 at 09:30
1

Try this this can be helpful for you

Vijju
  • 3,458
  • 1
  • 22
  • 20
1

Be simple... don't make every thing dynamic, unless it would be a critical thing. Use sqllite, txt file or xml to store the lists of names, pathes ... etc.

It will increase the performance dramatically.

Best

Anas2004
  • 326
  • 4
  • 9
1

Use MediaStore and ListAdapter. MediaStore is already managing thumbnails and filesystem paths for all media types (photo, video and audio).

Here's an article covering the basics of content providers, aka databases, which is what MediaStore is.

Here's an example of querying MediaStore for videos.

Also, this stackoverflow question seems similar to what you're doing.

One more thing: if you need to load media over the network (instead of local filesystem) then use the ContentProvider+Service technique described by Virgil Dobjanschi in his talk from Google I/O 2010 (video,pdf). At first it will seeem like overkill but the upfront work will pay repeated dividends in performance, avoiding caching bugs and avoiding rework.

Community
  • 1
  • 1
Peter Tran
  • 1,626
  • 1
  • 17
  • 26