Android的 - 从游标获取专辑艺术家 [英] Android - Getting Album Artist from Cursor
问题描述
我目前正在创建一个音乐播放器,我使用游标这样检索音乐设备上
I am currently creating a music player and I am retrieving the music on the device using a Cursor as such
mCursor = getContentResolver().query(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,
requestedColumns, null, null, null);
其中,
private String[] requestedColumns =
{
MediaStore.Audio.Media.TITLE,
MediaStore.Audio.Media._ID,
MediaStore.Audio.Media.DATA,
MediaStore.Audio.Media.ALBUM,
MediaStore.Audio.Media.ALBUM_ID,
MediaStore.Audio.Media.ARTIST,
MediaStore.Audio.Media.ARTIST_ID,
MediaStore.Audio.Media.YEAR,
MediaStore.Audio.Media.DURATION,
};
现在这是工作完美,我成功地取回我的设备/ SD卡音乐。我的问题是:有没有办法让在专辑歌手作为一个特定的歌曲?现在我不只是指partcular的艺术家的歌曲,而是从一首歌曲属于整张专辑背后的主要艺术家。似乎没有受到某种 MediaStore.Audio.Media.ALBUM_ARTIST
的。
Now this is working perfectly and I am successfully retrieving music on my device/SD Card. My questions is: is there any way to get the Album artist for a particular song? Now I don't simply mean the artist of a partcular the song, but the main artist behind the entire album from which a song belongs. There does not seem to be some kind of MediaStore.Audio.Media.ALBUM_ARTIST
.
在一个侧面说明:是什么使用 MediaStore.Audio.Media.ALBUM
和 MediaStore.Audio.ALBUMS之间的差异(如有)
On a side note: what is the difference (if any) between using MediaStore.Audio.Media.ALBUM
and MediaStore.Audio.ALBUMS
?
推荐答案
我想你正在寻找的是 MediaStore.Audio.Albums.ARTIST
,你可以看看成一个两阶段的过程的第二部分
I think what you are looking for is MediaStore.Audio.Albums.ARTIST
, which you can look up as the second part of a two-stage process.
Cursor cursor = getActivity().managedQuery(
MediaStore.Audio.Albums.EXTERNAL_CONTENT_URI,
new String[] {MediaStore.Audio.Albums._ID, MediaStore.Audio.Albums.ARTIST},
MediaStore.Audio.Albums._ID+ "=?",
new String[] {albumId},
null);
其中, ALBUMID
是歌曲,即你在你刚才的查询已经得到的相册ID: MediaStore.Audio.Media.ALBUM_ID
Where albumId
is the album id of the song, ie what you have gotten in your earlier query: MediaStore.Audio.Media.ALBUM_ID
MediaStore.Audio.ALBUMS
想象成你所有的专辑元数据。 MediaStore.Audio.Media.ALBUM
指的是专辑此音频文件是从。 新闻
总是元数据每个单独的文件。
Think of MediaStore.Audio.ALBUMS
as metadata about all your albums. MediaStore.Audio.Media.ALBUM
refers to the album this audio file is from. Media
is always metadata about each individual file.
这篇关于Android的 - 从游标获取专辑艺术家的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!