3
我對iPhone和ios開發中的音頻播放非常新穎。我想在我的應用程序中播放iPod庫中的歌曲。我在Google中搜索了我的最佳水平。但是,我得到了使用iPod庫的答案,但是,我不知道要從iPod庫播放選定的歌曲。這是我的代碼中使用的應用程序,如何從iPod應用程序中的iPod庫播放歌曲?
MPMediaPickerController *picker = [[MPMediaPickerController alloc] initWithMediaTypes: MPMediaTypeMusic];
picker.delegate = self;
picker.allowsPickingMultipleItems = NO;
picker.prompt = NSLocalizedString (@"Select songs to play", "Prompt in media item picker");
[self presentModalViewController:picker animated:YES];
[picker release];
- (void) mediaPicker: (MPMediaPickerController *) mediaPicker didPickMediaItems: (MPMediaItemCollection *) mediaItemCollection
{
[self dismissModalViewControllerAnimated: YES];
NSLog(@"MediaItemCollection : %@", mediaItemCollection);
MPMediaQuery *everything = [[MPMediaQuery alloc] init];
NSLog(@"Logging items from a generic query...");
NSArray *itemsFromGenericQuery = [everything items];
for (MPMediaItem *song in itemsFromGenericQuery)
{
NSString *songTitle = [song valueForProperty: MPMediaItemPropertyTitle];
NSLog (@"%@", songTitle); // Here i retrieved all song titles.
}
}
任何人都可以請建議我播放從iPod庫的歌曲?
使用[MPMusicPlayerController(http://developer.apple.com/library/ios/#documentation/mediaplayer/reference/MPMusicPlayerController_ClassReference/Reference/Reference.html) – bobobobo 2013-05-15 17:59:33