I am trying to get thumbnail of more then 10 videos from server to Image-view in android. Now i am successfully able to display thumbnail's of videos into image-view but my problem is it is taking too much time to display all thumbnail's. So it is showing blank black screen till it load all thumbnail's.
So i decided to use Asynctask that show's progress bar till it load's all thumbnail's but it doesn't show progress bar at all. So any idea how to solve this issue.
Code
ImageView video_one, video_two, video_three, video_four, video_five;
ImageView video_six, video_seven, video_eight, video_nine, video_ten;
ImageView video_ele, video_twe, video_thir, video_fort, video_fif;
String path = "http://serverlink/Fidol/upload/test.mp4";
String path1 = "http://serverlink/Fidol/upload/ABCD.mp4";
String path2 = "http://serverlink/Fidol/upload/bean.mp4";
String path3 = "http://serverlink/Fidol/upload/masti.mp4";
String path4 = "http://serverlink/Fidol/upload/ben.mp4";
Bitmap bm = ThumbnailUtils.createVideoThumbnail(path,
MediaStore.Images.Thumbnails.MICRO_KIND);
Bitmap bm1 = ThumbnailUtils.createVideoThumbnail(path1,
MediaStore.Images.Thumbnails.MICRO_KIND);
Bitmap bm2 = ThumbnailUtils.createVideoThumbnail(path2,
MediaStore.Images.Thumbnails.MICRO_KIND);
Bitmap bm3 = ThumbnailUtils.createVideoThumbnail(path3,
MediaStore.Images.Thumbnails.MICRO_KIND);
Bitmap bm4 = ThumbnailUtils.createVideoThumbnail(path4,
MediaStore.Images.Thumbnails.MICRO_KIND);
then i have called
new loadThumbnail().execute();
and here is my asynctask class
class loadThumbnail extends AsyncTask<String, String, String> {
@Override
protected void onPreExecute() {
super.onPreExecute();
pDialog = new ProgressDialog(ShowVideo.this);
pDialog.setMessage("Loading Videos... Please wait...");
pDialog.setIndeterminate(false);
pDialog.setCancelable(true);
pDialog.show();
}
protected String doInBackground(String... args) {
video_one.setImageBitmap(bm);
video_two.setImageBitmap(bm1);
video_three.setImageBitmap(bm2);
video_four.setImageBitmap(bm3);
video_five.setImageBitmap(bm4);
video_six.setImageBitmap(bm);
video_seven.setImageBitmap(bm1);
video_eight.setImageBitmap(bm2);
video_nine.setImageBitmap(bm3);
video_ten.setImageBitmap(bm4);
video_ele.setImageBitmap(bm);
video_twe.setImageBitmap(bm1);
video_thir.setImageBitmap(bm2);
video_fort.setImageBitmap(bm3);
video_fif.setImageBitmap(bm4);
return null;
}
protected void onPostExecute(String file_url) {
pDialog.dismiss();
}
}