我正在尝试获取艺术家的所有专辑,我尝试了以下代码但没有帮助..
Uri uri = MediaStore.Audio.Artists.Albums.getContentUri("external", click_no);
final String artist_name = MediaStore.Audio.Artists.Albums.ALBUM;
final String artist_image_path=MediaStore.Audio.Artists.Albums.ALBUM_ART;
final String[]columns={artist_name,artist_image_path};
//String String_id = //MediaStore.Audio.Artists._ID
//+ "=?";
int ii=0;
String orderBy = MediaStore.Audio.Artists.Albums.ALBUM;
Cursor cursor = managedQuery(uri, columns,null,null,null);
//String_id, whereVal, orderBy);
if(cursor != null){
while(cursor.moveToNext()) {
img[ii]= cursor.getString(1);
ii=ii+1;
}
}
答案 0 :(得分:0)
试试我的代码。只需将filePath传递给它。
private void showMetaData(String filePath){
MediaMetadataRetriever metaDataRetriver= new MediaMetadataRetriever();
metaDataRetriver.setDataSource(filePath);
try {
byte[] art= metaDataRetriver.getEmbeddedPicture();
Bitmap songImage= BitmapFactory.decodeByteArray(art, 0, art.length);
yourImageView.setImageBitmap(songImage);
} catch (Exception e) {
Log.v("TAG", e.toString());
}
try {
yourSongTitleTextView.setText(metaDataRetriver.extractMetadata(MediaMetadataRetriever.METADATA_KEY_TITLE));
} catch (Exception e) {
Log.v("TAG", e.toString());
}
try {
yourAlbumNameTextView.setText(metaDataRetriver.extractMetadata(MediaMetadataRetriever.METADATA_KEY_ALBUM));
} catch (Exception e) {
Log.v("TAG", e.toString());
}
try {
yourArtistNameTextView.setText(metaDataRetriver.extractMetadata(MediaMetadataRetriever.METADATA_KEY_ARTIST));
} catch (Exception e) {
Log.v("TAG", e.toString());
}
}