我必须从我的应用程序中的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);
    }
}


现在,我想允许该应用程序在单击按钮时下载特定的曲目。我怎样才能做到这一点?

最佳答案

您所需要做的就是iTunes商店中曲目的ID。
然后按照本教程在您的应用程序中显示商店UI:

Making Store Purchases with the SKStoreProductViewController Class

该库使您可以在iTunes Store中搜索(以获取ID):https://github.com/gangverk/iTunesSearch

关于ios - 如何从iTunes Store Xcode下载特定轨道,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/13658206/

10-13 04:08