【问题标题】:Receiving album art in android 11在 android 11 中接收专辑封面
【发布时间】:2021-03-29 18:32:28
【问题描述】:

作为known,ALBUM_ART 在Android 11 中已被弃用。Google 表示应该改用ContentResolver.loadThumbnail。但我完全不明白如何使用它,尤其是我应该提供的第一个参数 uri。文档说:

Uri:应显示为缩略图的项目。该值不能为空。

那是什么物品,我怎样才能得到它?这是音乐文件的 Uri 吗?

【问题讨论】:

  • 你现在已经尝试过了,所以你可以告诉我们。

标签: java android kotlin thumbnails


【解决方案1】:

你需要传入track的Uri。

//This will get you the uri of the track, if you already have the track id
Uri trackUri = ContentUris.withAppendedId(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, trackId);
Bitmap bm = contentResolver.loadThumbnail(trackUri, new Size(512,512), null);

将位图设置为 ImageView

imageView.setImageBitmap(bm);

【讨论】:

  • Ait 工作正常,谢谢。但不幸的是,毕加索无法从盒子中加载位图。是不是获取缩略图的uri的方式?
  • track id 是什么?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-11-15
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多