我必须从我的应用程序上的Button Click下载iTunes音乐商店中的特定曲目。我无法确切地知道如何执行此操作。
我已经实现了以下代码来获取播放列表中的播放列表和歌曲:
-(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);
}
}
现在我想让应用程序在点击按钮时下载特定的曲目。我怎么能这样做?
答案 0 :(得分:3)
您只需要iTunes商店中曲目的ID即可。 然后按照本教程在您的应用中显示商店用户界面:
Making Store Purchases with the SKStoreProductViewController Class
此库允许您在iTunes Store中搜索(以获取ID):https://github.com/gangverk/iTunesSearch