Given an Android music playlist name, how can one find the songs in the playlist?

后端 未结 3 1883
无人共我
无人共我 2020-12-01 17:41

The playlist names can be found by a query on MediaStore.Audio.Playlists.EXTERNAL_CONTENT_URI and then look at the MediaStore.Audio.PlaylistsColumns.NAME<

3条回答
  •  情话喂你
    2020-12-01 18:11

    this is the way to get all playlist from the device

    public ArrayList getPlayList() {
    
                ArrayList arrayList=new ArrayList();
    
                String[] proj = {"*"};
                Uri tempPlaylistURI = MediaStore.Audio.Playlists.EXTERNAL_CONTENT_URI;
    
                // In the next line 'this' points to current Activity. 
                // If you want to use the same code in other java file then activity, 
                // then use an instance of any activity in place of 'this'. 
    
                Cursor playListCursor= activity.managedQuery(tempPlaylistURI, proj, null,null,null);
    
                if(playListCursor == null){
                    System.out.println("Not having any Playlist on phone --------------");
                    return arrayList;//don't have list on phone 
                } 
    
                System.gc();
    
                String playListName = null;
    
                System.out.println(">>>>>>>  CREATING AND DISPLAYING LIST OF ALL CREATED PLAYLIST  <<<<<<");
    
                for(int i = 0; i  " + i + "  : " + playListName );
                    arrayList.add(playListName);
                } 
    
                if(playListCursor != null)
                    playListCursor.close();
    
                return arrayList;
    
    
    
            }
    

提交回复
热议问题