尝试像在 AsyncTask 中加载每个:
private class LoadImageTask extends AsyncTask<String, Void, Bitmap>{
private ImageView artImage;
public LoadImageTask(ImageView image){
artImage = image;
}
@Override
protected void onPreExecute() {
retriever = new MediaMetadataRetriever();
}
@Override
protected Bitmap doInBackground(String... params) {
retriever.setDataSource(params[0]);
byte[] art = retriever.getEmbeddedPicture();
Bitmap bitmap = null;
if( art != null ){
bitmap = BitmapFactory.decodeByteArray(art, 0, art.length);
}
return bitmap;
}
@Override
protected void onPostExecute(Bitmap bm) {
if( bm != null ){
artImage.setImageBitmap(bm);
}
else{
artImage.setImageResource(R.drawable.no_image);
}
}
}