I have to download a specific track from iTunes Music store on Button Click from my app. I am not able to find exactly how this can be performed.
I have implemented the following code to fetch the play list and songs in the playlist:
-(void)musicPlaylist{
playlistQuery= [MPMediaQuery playlistsQuery];
NSArray *arr = [playlistQuery collections];
NSLog(@"Playlist is : %@",arr);
int count1=[arr count];
NSLog(@" count 1 is %d",count1);
for (MPMediaPlaylist *playlist in arr) {
NSLog (@"%@", );
playlistTitle = ;
playlistDict=[NSDictionary dictionaryWithObjectsAndKeys:playlistTitle,@"playlist Title",nil];
[dictArray addObject:playlistDict];
NSArray *songs = ;
for (MPMediaItem *song in songs) {
NSString *songTitle =[song valueForProperty: MPMediaItemPropertyTitle];
[songArray addObject:songTitle];
}
NSLog(@"Playlist is %@",playlistTitle);
NSLog(@"Playlist Songs are %@",songArray);
}
}
Now I want to allow the app to download a specific track on button click. How can I do that?
All you need is the ID of the track in the iTunes store.
Then follow this tutorial to present the store UI in your app:
Making Store Purchases with the SKStoreProductViewController Class
This library allows you to search in the iTunes Store (in order to get the ID): https://github.com/gangverk/iTunesSearch