views:

12

answers:

0

Hello all,

After selecting a movie from the camera roll the first frame of the movie appears but after pressing play the movie disappears and won't play... Been racking my brain for days and can't figure this one out. The code used to work but doesn't seem to work on the latest version of the SDK

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {

if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
    [popover dismissPopoverAnimated:YES];

}
else {
    [picker dismissModalViewControllerAnimated:YES];
}

NSString* mediaType = [info objectForKey:UIImagePickerControllerMediaType];
if (CFStringCompare((CFStringRef) mediaType, kUTTypeImage, 0) == kCFCompareEqualTo) {               
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Warning",@"") message:NSLocalizedString(@"Please select a movie and not a photo, try again!",@"")
                                                   delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil];
    [alert show];   
    [alert release];
    return;
}

NSString *moviepath = [[info objectForKey:UIImagePickerControllerMediaURL] path];
movieURL = [NSURL fileURLWithPath:moviepath];
moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:movieURL];    

moviePlayer.scalingMode = MPMovieScalingModeAspectFill; 
moviePlayer.controlStyle = MPMovieControlStyleEmbedded;
moviePlayer.shouldAutoplay = NO;

if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
    moviePlayer.view.frame = CGRectMake(0, 0, 768, 1024);
}
else {
    moviePlayer.view.frame = CGRectMake(0, 0, 320, 480);
}

[self.view addSubview:moviePlayer.view];    

}