I can't speak to the legality issues in doing this, or what programs you may/may not need to join, but I can give you a simple example of how to interact with the iTunes Search API. It's all actually pretty straight forward actually, pass the server a specifically formatter URL and get JSON data back regarding the query results.
NSUInteger numberOfResults = 200;
NSString *searchString = @"AC/DC";
NSString *encodedSearchString = [searchString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSString *finalSearchString = [NSString stringWithFormat:@"https://itunes.apple.com/search?term=%@&entity=song&limit=%u",encodedSearchString,numberOfResults];
NSURL *searchURL = [NSURL URLWithString:finalSearchString];
dispatch_queue_t iTunesQueryQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, kNilOptions);
dispatch_async(iTunesQueryQueue, ^{
NSError *error = nil;
NSData *data = [[NSData alloc] initWithContentsOfURL:searchURL options:NSDataReadingUncached error:&error];
if (data && !error) {
NSDictionary *JSON = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil];
NSArray *array = [JSON objectForKey:@"results"];
NSLog(@"%@",array);
}
});
Once you receive the JSON data, you'll notice that there is a key for every result called "previewUrl" this data can be passed to a player of your choice (I used MPMoviePlayerController
) and from there all you have to do is call play!