Software Engineer
Software Engineer

Reputation: 131

"imagePickerController:didFinishPickingMediaWithInfo:" "UIImagePickerControllerMediaURL" key strange behavior in info dictionary

In "imagePickerController:didFinishPickingMediaWithInfo:" the info dictionary sometimes doesn't have the key "UIImagePickerControllerMediaURL". Sometimes it does have. I tried cleaning the targets but that didn't help. Also, the workflow is always the same: I follow the same steps and choose the same video file from library. Sometime info dictionary has "UIImagePickerControllerMediaURL" key in it and sometime "UIImagePickerControllerMediaURL" is absent in the info dictionary itself for the same file. Could not understand it. Can somebody help ?

This is my NSLog of info dictionary when i select video/movie from photos library :

info dict = {
    UIImagePickerControllerMediaType = "public.movie";
    UIImagePickerControllerReferenceURL = "assets-library://asset/asset.MOV?id=1000000466&ext=MOV";
} 

Upvotes: 4

Views: 7436

Answers (2)

vien vu
vien vu

Reputation: 4337

It happen when your account Video save on iCloud. When you choose video it will temporarily download from icloud and show to you so UIImagePickerControllerMediaURL will don't appear.

Upvotes: 0

GhostRider
GhostRider

Reputation: 1207

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

{ 
    NSMutableDictionary *infoDict = [[NSMutableDictionary alloc]init];

    NSString *mediaType = [info objectForKey:UIImagePickerControllerMediaType];

    if ([mediaType isEqualToString:@"public.image"]){

        UIAlertView *myAlertView = [[UIAlertView alloc] initWithTitle:@"" message:@"You Select a image Please select Movie" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];

        [myAlertView show];

        [myAlertView release];

    }

    else if ([mediaType isEqualToString:@"public.movie"]){

        NSURL *videoURL = [info objectForKey:UIImagePickerControllerMediaURL];

        mAppDelegate.uploadType = @"Video";

        NSData *webData = [NSData dataWithContentsOfURL:videoURL];

        [infoDict setValue:webData forKey:@"VideoUrl"];

        [infoDict setValue:[[mAppDelegate.userInfoArray objectAtIndex:1]valueForKey:@"user_id"] forKey:@"user_id"];

        [[WakeUpParsing sharedInstance] assignSender:self];

        [[WakeUpParsing sharedInstance] startParsingForVedioUploade:infoDict];

    }

    [picker dismissModalViewControllerAnimated:YES];

    [infoDict release];

}


- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker

{

    // Dismiss the image selection and close the program
    [[picker parentViewController] dismissModalViewControllerAnimated:YES];

}

Upvotes: 4

Related Questions