需要获得流派专辑艺术

时间:2015-11-28 09:36:50

标签: android android-contentprovider audio-player android-music-player

这是我的示例代码,它能够很好地处理我能够获得此类型下所有相册的所有元素......

但在此之前,我检索了我从

查询的类型ID

MediaStore.Audio.Genres.EXTERNAL_CONTENT_URI

我投放了类型名称和id 的投影,我能够完全正常但是有了这些信息,我需要有类型专辑艺术, 我其实不知道怎么才能得到它。

{
        int genreId = 2; // << Set Your Genre ID Here
        Uri uri = MediaStore.Audio.Albums.getContentUri("external");
        Log.i("XXX", "uri = " + uri.toString());
        Cursor cursor = null;
        try {

            String selection = "album_info._id IN "
                    + "(SELECT (audio_meta.album_id) album_id FROM audio_meta, audio_genres_map "
                    + "WHERE audio_genres_map.audio_id=audio_meta._id AND audio_genres_map.genre_id=?)";
            String[] selectionArgs = new String[] { String.valueOf(genreId) };
            String[] proj = { AlbumColumns.ALBUM };
            cursor = getContentResolver().query(uri, proj, selection,
                    selectionArgs, null);
            if (null != cursor) {
                Log.i("XXX", "cursor rows count = " + cursor.getCount());
                while (cursor.moveToNext()) {
                    Log.i("XXX", "  Album: " + cursor.getString(0));
                }
                cursor.close();
                Log.i("XXX", "cursor closed");
            }
        } catch (Exception ex) {
            Log.e("XXX", "Error Querying Database");
        } finally {
            if (cursor != null) {
                cursor.close();
            }
        }
    }

0 个答案:

没有答案