Problems with MPMediaPickerController.
With the code below. The musicPlayer does not play on my device at all. I am running iOS 5 and I get some weird cryptic warnings in the console like wait_fences no reply and Invalid Track
Here is the code:
- (IBAction)openMediaPicker:(id)sender {
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationFade];
MPMediaPickerController *mediaPicker = [[MPMediaPickerController alloc] initWithMediaTypes:MPMediaTypeAny];
mediaPicker.delegate = self;
mediaPicker.allowsPickingMultipleItems = YES;
mediaPicker.prompt = @"Select songs to play";
[self presentModalViewController:mediaPicker animated:YES];
[mediaPicker release];
}
- (void)mediaPicker: (MPMediaPickerController *)mediaPicker didPickMediaItems:(MPMediaItemCollection *)mediaItemCollection {
AppTestAppDelegate *appDelegate = (AppTestAppDelegate *)[[UIApplication sharedApplication] delegate];
[appDelegate.tr2 stop];
if (mediaItemCollection) {
self.musicPlayer = [MPMusicPlayerController iPodMusicPlayer];
[self.musicPlayer setQueueWithItemCollection:mediaItemCollection];
[self.musicPlayer play];
}
[playstopButton setHidden:NO];
[playstopButton setImage:[UIImage imageNamed:@"Stop-Music-Button.png"] forState:UIControlState开发者_如何学运维Normal];
// We need to dismiss the picker
[self dismissModalViewControllerAnimated:YES];
[[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationFade];
}
There are no crashes or anything but it just doesn't play anything
Does anything look wrong here? Why isn't it working?
Thanks!
精彩评论