0

My app works fine iPhone but now that i am porting to iPad, to choose videos from gallery we have to use UIPopoverController (which is a property with nonatomic attribute) while dismissing popover in imagePickerController:

- (UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info

delegate method it automatically calls my didFinishMovie and terminates it.

-(void)showPopOverGalleryusingDelegate:(id )delegate {

    if ([self.popover isPopoverVisible]) {
        [self.popover dismissPopoverAnimated:YES];
    } else {
        if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeSavedPhotosAlbum] )
        {
            UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
            imagePicker.delegate = delegate;
            imagePicker.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;
            imagePicker.mediaTypes = [[NSArray alloc] initWithObjects: (NSString *) kUTTypeMovie, nil];
            imagePicker.allowsEditing = NO;

            self.popover = [[UIPopoverController alloc]
                            initWithContentViewController:imagePicker];


            CGRect popoverRect = [self.view convertRect:[_galleryButton frame]
                                               fromView:[_galleryButton superview]];
         [self.popover presentPopoverFromRect:popoverRect inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
        }
}

}

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

// 1 - Get media type
NSString *mediaType = [info objectForKey: UIImagePickerControllerMediaType];
// 2 - Dismiss image picker
[self dismissViewControllerAnimated:NO completion:nil];

if (_popover != nil) {
    [_popover dismissPopoverAnimated:YES];
    _popover=nil;
}
// Handle a movie capture
if (CFStringCompare ((__bridge_retained CFStringRef)mediaType, kUTTypeMovie, 0) == kCFCompareEqualTo) {
    // 3 - Play the video

    NSLog(@"imageDelegate");
    _vURL =[info objectForKey:UIImagePickerControllerMediaURL];

    _theMovie = [[MPMoviePlayerViewController alloc]
                                             initWithContentURL:_vURL];



    _theMovie.moviePlayer.controlStyle = MPMovieControlStyleNone;
    _theMovie.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;

    [self presentViewController:_theMovie  animated:YES completion:nil];
    [_theMovie.moviePlayer prepareToPlay];


    // 4 - Register for the playback finished notification
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(myMovieFinishedCallback:)
                                                 name:MPMoviePlayerPlaybackDidFinishNotification object:_theMovie.moviePlayer];


   [_theMovie.moviePlayer play];
   [self customPlaybackControls];


}

}

this is pretty unusual from my experience and i can't get to bottom of this on my own, i need a new perspective on this, many thanks.

3
  • Could you clarify your problem? It is a bit unclear.
    – Groot
    Jun 13, 2013 at 10:01
  • when user selects the video from popover , program calls imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info delegate method which dismisses popover , but as soon as popover is dismissed my MPMoviePlayerController assumes movie has finished and calls didFinishMovieCallback: , the movie picked by user never gets played by movie player controller Jun 13, 2013 at 10:05
  • somehow dismissing the popover is connected to movieplayer assuming its playback is finished, which is an unwanted behaviour Jun 13, 2013 at 10:12

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.