2
음악 앱과 매우 흡사하게 노래의 이름 (파일 이름 아님) 또는 아티스트 또는 앨범에 액세스하려고합니다. 예를 들어, 전화상의 모든 노래의 이름을 listview에 채우고 싶습니다.어떻게 안드로이드에 저장된 음악의 이름, 아티스트, 앨범 이름에 액세스합니까?
음악 앱과 매우 흡사하게 노래의 이름 (파일 이름 아님) 또는 아티스트 또는 앨범에 액세스하려고합니다. 예를 들어, 전화상의 모든 노래의 이름을 listview에 채우고 싶습니다.어떻게 안드로이드에 저장된 음악의 이름, 아티스트, 앨범 이름에 액세스합니까?
음악 파일 자체에서 메타 태그를 읽는 방법과 MediaStore
콘텐츠 공급자를 사용하는 방법이 있습니다. MediaStore
은 본질적으로 여러분이 전화에 관한 모든 미디어 관련 정보를 쿼리 할 수있는 공개 데이터베이스입니다.
MediaStore
을 사용하는 것은 매우 간단하며 문서 here에서 찾을 수 있습니다.
String[] proj = { MediaStore.Audio.Media._ID,
MediaStore.Audio.Media.DATA,
MediaStore.Audio.Media.DISPLAY_NAME,
MediaStore.Audio.Artists.ARTIST };
tempCursor = managedQuery(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,
proj, null, null, null);
tempCursor.moveToFirst(); //reset the cursor
int col_index=-1;
int numSongs=tempCursor.getCount();
int currentNum=0;
do{
col_index = tempCursor.getColumnIndexOrThrow(MediaStore.Audio.Artists.ARTIST);
artist = tempCursor.getString(col_index);
//do something with artist name here
//we can also move into different columns to fetch the other values
}
currentNum++;
}while(tempCursor.moveToNext());
: 여기
내 응용 프로그램 중 하나에서 간단한 예입니다