Querying Playlist from MediaStore

后端 未结 3 1316
盖世英雄少女心
盖世英雄少女心 2021-01-07 06:33

I\'m trying to query playlists in the device from MediaStore. I have followed a question asked before but I didn\'t get the answer.

This is how I query for playlist

3条回答
  •  说谎
    说谎 (楼主)
    2021-01-07 06:58

    Example to populate an array :

               Cursor cursor = plist.getPlaylistTracks(getActivity(), playlist_id);
         // replace with your own method to get cursor
        ArrayList audio_ids = new ArrayList();
    
        // build up the array with audio_id's
        int i = 0;
        if (cursor != null && cursor.moveToFirst()) {
            for (cursor.moveToFirst(); !cursor.isAfterLast(); cursor.moveToNext()) {
                String audio_id = cursor.getString(cursor.getColumnIndex(MediaStore.Audio.Playlists.Members.AUDIO_ID));
                audio_ids.add(audio_id);
            }
    

    Make sure that when you assign audio_id (or your own variable) you use the correct MediaStore uri as used when you obtained the cursor. The column names in your cursor determine what you can get here.

提交回复
热议问题