获取歌曲的流派
回答
当它被设置在那里时,你可以从它自己的mp3文件中分别从它的ID3标签中得到它。应该有一些java库在那里帮助你从mp3文件访问这些标签。
是的,但是通过MediaStore无法做到这一点?这就是我要找的。 – Jeff 2010-09-16 20:33:17
检查这个代码:
public class MusicLibraryScanner {
private static Cursor mediaCursor;
private static Cursor genresCursor;
private static String[] mediaProjection = {
MediaStore.Audio.Media._ID,
MediaStore.Audio.Media.ARTIST,
MediaStore.Audio.Media.ALBUM,
MediaStore.Audio.Media.TITLE
};
private static String[] genresProjection = {
MediaStore.Audio.Genres.NAME,
MediaStore.Audio.Genres._ID
};
public static void getMusicFromStorage(Context context) {
mediaCursor = context.getContentResolver().query(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,
mediaProjection, null, null, null);
int artist_column_index = mediaCursor
.getColumnIndexOrThrow(MediaStore.Audio.Media.ARTIST);
int album_column_index = mediaCursor
.getColumnIndexOrThrow(MediaStore.Audio.Media.ALBUM);
int title_column_index = mediaCursor
.getColumnIndexOrThrow(MediaStore.Audio.Media.TITLE);
int id_column_index = mediaCursor
.getColumnIndexOrThrow(MediaStore.Audio.Media._ID);
if (mediaCursor.moveToFirst()) {
do {
String info = "Song " + mediaCursor.getString(title_column_index) + " ";
info += "from album " + mediaCursor.getString(album_column_index) + " ";
info += "by " + mediaCursor.getString(artist_column_index) + ". ";
int musicId = Integer.parseInt(mediaCursor.getString(id_column_index));
Uri uri = MediaStore.Audio.Genres.getContentUriForAudioId("external", musicId);
genresCursor = context.getContentResolver().query(uri,
genresProjection, null, null, null);
int genre_column_index = genresCursor.getColumnIndexOrThrow(MediaStore.Audio.Genres.NAME);
if (genresCursor.moveToFirst()) {
info += "Genres: ";
do {
info += genresCursor.getString(genre_column_index) + " ";
} while (genresCursor.moveToNext());
}
Log.e("Audio scanner", "Song info: " + info);
} while (mediaCursor.moveToNext());
}
}
}
getContentUriForAudioId函数是什么? – 2014-07-03 11:30:26
我已经使用它,但它在android 2.3.5中崩溃,因为在android 2.3.6中没有Method。请帮助我的较低版本的设备。 – 2014-07-07 12:43:33
这将只给你所有流派的列表,但不包括哪首歌曲属于哪首歌曲 – jazz 2016-07-26 19:34:41
如果你还在寻找一个答案-----
MediaMetadataRetriever mr = new MediaMetadataRetriever();
Uri trackUri = ContentUris.withAppendedId(
android.provider.MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,song_id);
mr.setDataSource(mContext, trackUri);
String thisGenre = mr.extractMetadata(MediaMetadataRetriever.METADATA_KEY_GENRE);
- 1. 从每首歌曲获取HTTP MP3流
- 2. 有什么方法可以使用MediaStore获取歌曲的流派?
- 3. 如何在Android中的一个查询中获得各个流派的流派和歌曲数量?
- 4. 歌曲#流派中的NoMethodError。未定义的方法'each'for nil:NilClass
- 5. 从歌曲获取ALBUM_ART
- 6. 获取歌曲元数据
- 7. ExoPlayer:从HTTP流获取歌曲的元数据
- 8. Soundcloud:获取向歌曲组贡献歌曲的所有用户
- 9. 如何从itunes库中获取只有歌曲的歌曲itlibrary.h
- 10. 使用Applescript在iTunes中获取流媒体曲目的歌曲名称
- 11. 流歌曲使用的GameKit
- 12. 获取音乐流派中的YouTube
- 13. 歌词与歌曲的关联流程
- 14. python icecast/shoutcast流代理,添加流派/歌曲名称/艺术家元数据?
- 15. 从soundcloud获取歌曲信息,歌曲ID为
- 16. 如何获取歌曲标题? Android的
- 17. 如何从MediaLibrary获取歌曲的URI?
- 18. 在Android中获取歌曲的BPM
- 19. 获取歌曲文件头的问题
- 20. AVFoundation获取歌曲的专辑图像
- 21. 查询:获取歌曲的作者并统计该作者的歌曲总数
- 22. 通过Android获取歌曲信息
- 23. 在javascript中获取mp3歌曲时长
- 24. 如何从mediastore获取歌曲?
- 25. WP7如何获取当前歌曲
- 26. 如何从iTunes获取歌曲信息?
- 27. 按歌曲获取封面图片
- 28. 从Spotify API获取随机歌曲
- 29. Spotify API:获取随机歌曲
- 30. 从ipods获取歌曲名称
我也在寻找相同。 – Sandy 2010-12-31 08:25:46
看[这里] [1] [1]:http://stackoverflow.com/questions/9785370/display-all-song-from-the-sd-card-genre-wise – user4232 2012-05-08 09:24:27