有人可以逐行向我解释吗?我不想在不了解我实际在做什么的情况下复制粘贴的东西
Uri sArtworkUri = Uri.parse("content://media/external/audio/albumart");
Uri uri = ContentUris.withAppendedId(sArtworkUri, album_id);
ContentResolver res = context.getContentResolver();
InputStream in = res.openInputStream(uri);
Bitmap artwork = BitmapFactory.decodeStream(in);
我正在尝试在下面的代码中使用上面的代码来获取音乐艺术家和专辑等......................
………………………………………………………………………………………………………………………………………… …………………………………………………………………………………………………………………………………………
public ArrayList<SongDetails> getSongsFromDirectory(File f)
{MediaMetadataRetriever mmr = new MediaMetadataRetriever();
ArrayList<SongDetails> songs = new ArrayList<SongDetails>();
if (!f.exists() || !f.isDirectory())
{
return songs;
}
File[] files = f.listFiles(new Mp3Filter());
for(int i=0; i<files.length; i++)
{
Uri uri = Uri.fromFile(files[i]);
//mmr.setDataSource(null, uri);
if (files[i].isFile()){
SongDetails detail=new SongDetails();
detail.setIcon(R.drawable.ic_launcher);
detail.setSong(files[i].getName());
//detail.setArtist(mmr.extractMetadata(MediaMetadataRetriever.METADATA_KEY_ARTIST));
//detail.setAlbum(mmr.extractMetadata(MediaMetadataRetriever.METADATA_KEY_ALBUM));
songs.add(detail);
}else if (files[i].isDirectory()){
songs.addAll(getSongsFromDirectory(files[i]));
}
}
return songs;
} }