Question

I am an iOS Developer.I am working on iMusic Library.I need to fetch the particular particular playlist from iMusic Library in iOS SDK.Like "Recently added","Top 25" or any other playlist created by user manually.

Right now i am using the following code,by which i am able to get the whole iMusic Library,but now i need to fetch its particular playlist.

MPMediaQuery *media = [[MPMediaQuery alloc]init];
    NSArray *arr = [media items];
    int count1arr count];
    NSLog(@" count 1 is %d",count1);
    for(MPMediaItem *song in arr)
    {

        if(count>=count1)
        {
            return;
            count--;
        }
        else{
            //To print songs title
            NSString *title = [song valueForProperty:MPMediaItemPropertyTitle];
            NSString *artistsong valueForProperty:MPMediaItemPropertyAlbumArtist];
            NSLog(@"title is %@", title);
            NSLog(@"artist is %@",artist);

            if(artist == nil || [artist isEqualNSNull null]] || [artist isEqualToString:@""]){
                listDictNSDictionary dictionaryWithObjectsAndKeys:title,@"title",@"Unknown",@"artist", nil ];
                NSLog(@"List now is  %@",listDict);
                [dictArray addObject:listDict];
                NSLog(@"Dict array is %@",dictArray);
            }
            else{
                listDictNSDictionary dictionaryWithObjectsAndKeys:title,@"title",artist,@"artist", nil ];
                NSLog(@"List now is  %@",listDict);
                [dictArray addObject:listDict];
                NSLog(@"Dict array is %@",dictArray);

            }
        }
    }
    NSLog(@"List now is  %@",listDict);.

Thanks in Advance.

Was it helpful?

Solution

As you can read in the MPMediaQuery documentation you can create a playlist media query object by calling playlistsQuery on the MPMediaQuery class.

MPMediaQuery *playlistQuery = [MPMediaQuery playlistsQuery];
NSArray *playlistArray = [playlistQuery collections];
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top