【发布时间】:2017-12-04 00:17:30
【问题描述】:
public void getSongs() {
Uri songUri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
String selection = MediaStore.Audio.Media.IS_MUSIC + "!=0";
Cursor myCursor = getContentResolver().query(songUri, null, selection, null, null);
if (myCursor != null && myCursor.moveToFirst()) {
int id_Column = myCursor.getColumnIndexOrThrow(MediaStore.Audio.Media._ID);
int data_Column = myCursor.getColumnIndexOrThrow(MediaStore.Audio.Media.DATA);
int title_Column = myCursor.getColumnIndexOrThrow(MediaStore.Audio.Media.TITLE);
int artist_Column = myCursor.getColumnIndexOrThrow(MediaStore.Audio.Media.ARTIST);
int album_Column = myCursor.getColumnIndexOrThrow(MediaStore.Audio.Media.ALBUM_ID);
do {
Long songId = myCursor.getLong(id_Column);
String songData = myCursor.getString(data_Column);
String songName = myCursor.getString(title_Column);
String songArtist = myCursor.getString(artist_Column);
String songAlbum = myCursor.getString(album_Column);
long parseLong = Long.parseLong(songAlbum);
final Uri sArtWorkUri = Uri.parse("content://media/external/audio/albumart");
Uri uri = ContentUris.withAppendedId(sArtWorkUri, parseLong);
Picasso.with(this).load(uri).into(albumArt);
QuerySongs querySongs = new QuerySongs(songId, songData, songName, songArtist);
songList.add(querySongs);
} while (myCursor.moveToNext());
myCursor.close();
}
}
如何将专辑封面加载到 imageView?在我的 getSongs 方法中,我尝试了 Picasso,但没有加载艺术作品。
我该如何解决这个问题?
谢谢, -文斯
【问题讨论】:
-
毕加索.with(this).load(uri).into(albumArt);我知道我在这里遗漏了一些东西,但我不知道是什么。