IOS如何能UISaveVideoAtPathToSavedPhotosAlbum返回保存的videopath?

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { NSURL *videoURL = [info objectForKey:UIImagePickerControllerMediaURL]; //get the videoURL NSString *tempFilePath = [videoURL path]; if ( UIVideoAtPathIsCompatibleWithSavedPhotosAlbum(tempFilePath)) { // Copy it to the camera roll. UISaveVideoAtPathToSavedPhotosAlbum(tempFilePath, self, @selector(video:didFinishSavingWithError:contextInfo:), tempFilePath); } } 

我使用UISaveVideoAtPathToSavedPhotosAlbum保存录制的video。 我想知道我保存录制的video的专辑的绝对path。

我怎么能得到保存的path? UISaveVideoAtPathToSavedPhotosAlbum不返回任何。

并在callback函数video:didFinishSavingWithError:contextInfo:仍然没有path信息。

据我所知..你不能得到保存在相册中的video的path。 如果你想从你的应用程序重播文件列表。 您可以在应用程序中包含所有video。

以下是您的示例代码放在didFinishPickingMedia将video存储在边文档中..以便您可以跟踪它。

  NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; // Get documents folder NSString *dataPath = [documentsDirectory stringByAppendingPathComponent:[NSString stringWithFormat:@"%d", 1]]; NSString *fileName = [NSString stringWithFormat:@"%@ :%@.%@", itsIncidentType, [dateFormatter stringFromDate:incidentDate], @"mp4"]; [dateFormatter release]; if (![[NSFileManager defaultManager] fileExistsAtPath:dataPath]) [[NSFileManager defaultManager] createDirectoryAtPath:dataPath withIntermediateDirectories:NO attributes:nil error:&error]; //Create folder NSURL *videoURL = [imageInfo objectForKey:UIImagePickerControllerMediaURL]; NSData *webData = [NSData dataWithContentsOfURL:videoURL]; self.itsVideoName = fileName; [webData writeToFile:[NSString stringWithFormat:@"%@/%@",dataPath,fileName] atomically:TRUE]; 

希望这可以帮助你..