[英]How can i download a specific track from iTunes store xcode
I have to download a specific track from iTunes Music store on Button Click from my app. 我必须从我的应用程序中的Button Click上从iTunes音乐商店下载特定曲目。 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. 您所需要做的就是iTunes商店中曲目的ID。 Then follow this tutorial to present the store UI in your app: 然后按照本教程在您的应用程序中显示商店UI:
Making Store Purchases with the SKStoreProductViewController Class 使用SKStoreProductViewController类进行商店购买
This library allows you to search in the iTunes Store (in order to get the ID): https://github.com/gangverk/iTunesSearch 该库允许您在iTunes Store中搜索(以获取ID): https : //github.com/gangverk/iTunesSearch
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.