【发布时间】:2022-01-01 14:33:42
【问题描述】:
尝试使用 glide 从 url 加载音频缩略图但不工作
Glide
.with(this)
.load("http://api.boleiachain.com/upload/musictest.mp3")
.apply(options)
.centerCrop()
.placeholder(R.drawable.ic_loading)
.into(civ_image);
我已经试过了
public Bitmap coverpicture(String path) {
Bitmap bitmap=null;
MediaMetadataRetriever mediaMetadataRetriever = new MediaMetadataRetriever();
mediaMetadataRetriever.setDataSource(path, new HashMap<String, String>());
try {
final byte[] coverImage = mediaMetadataRetriever.getEmbeddedPicture();
bitmap= BitmapFactory.decodeByteArray(coverImage, 0, coverImage.length);
} catch (Exception e) {
e.printStackTrace();
}
return bitmap;
}
Glide
.with(this)
.load(coverpicture("http://api.boleiachain.com/upload/musictest.mp3"))
.apply(options)
.centerCrop()
.placeholder(R.drawable.ic_loading)
.into(civ_image);
它可以工作但有延迟,这在 recyclerView 适配器中不是一个好习惯
【问题讨论】:
-
无论如何,网络通话都需要时间,