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 (@"%@", [playlist valueForProperty: MPMediaPlaylistPropertyName]);
playlistTitle = [playlist valueForProperty: MPMediaPlaylistPropertyName];
playlistDict=[NSDictionary dictionaryWithObjectsAndKeys:playlistTitle,@"playlist Title",nil];
[dictArray addObject:playlistDict];
NSArray *songs = [playlist items];
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.