开发者

Getting efficiently the Genres of the Audio files in the MediaStore

I am trying to synchronize my own database for tracks and albums (that contains additional data). I have so far successfully pulled albums and tracks from the MediaStore.

What I cannot manage to do properly is to pull the Genres for the tracks. Could someone post some code? I'd like to avoi开发者_如何学God querying the database for each track, so if possible some code to load the association (Genre.id <-> Audio.id) would be great.

What I am struggling on is using the content provider to get the Genres.Members info.


I'd take a look at how the excellent creators of ringdroid do this. http://ringdroid.googlecode.com/svn-history/r37/trunk/src/com/ringdroid/SongMetadataReader.java

They basically start by retrieving the genres names and ids and using those they can easily create a content_uri that retrieves only songs in the database that matches those genres. But if I were you I would check whether there is an "unknown" or "empty" genre or not for the files that contain no Genre name in their id3 tag


So what I ended up doing is getting all audio files on the sd with a loader and following query:

        loader = new CursorLoader(mActivity, MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, 
                new String[] {Audio.Media._ID, Audio.Media.DATA}, 
                null, null, null);

Then i check if they end with .mp3 and I then use jaudiotagger and read the ide3 tags for genre.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜