我不知道为什么每个人都这么多关于从应用商店被拒绝的话.我将简要介绍如何开始.
- 现在使用Media Picker打开用户的iPod:
MPMediaPickerController *pickerController = [[MPMediaPickerController alloc] initWithMediaTypes:MPMediaTypeMusic];
pickerController.prompt = NSLocalizedString(@"Choose Song", NULL);
pickerController.allowsPickingMultipleItems = NO;
pickerController.delegate = self;
[self presentViewController:pickerController animated:YES completion:nil];
[pickerController release];
Run Code Online (Sandbox Code Playgroud)
- 等到用户选择一首歌并在mediaPicker委托中获得回调:
- (void)mediaPicker:(MPMediaPickerController *)mediaPicker didPickMediaItems:(MPMediaItemCollection *)mediaItemCollection
{
MPMediaItem *theChosenSong = [[mediaItemCollection items]objectAtIndex:0];
NSString *songTitle = [theChosenSong valueForProperty:MPMediaItemPropertyTitle];
NSString *artist = [theChosenSong valueForProperty:MPMediaItemPropertyArtist];
//then just get the assetURL
NSURL *assetURL = [theChosenSong valueForProperty:MPMediaItemPropertyAssetURL];
AVURLAsset *songAsset = [AVURLAsset URLAssetWithURL:assetURL options:nil];
//Now that you have this, either just write the asset (or part of) to disk, access the asset directly, send the written asset to another device etc
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1043 次 |
| 最近记录: |