IOS -how可以UISaveVideoAtPathToSavedPhotosAlbum返回保存的视频路径? [英] IOS -how could UISaveVideoAtPathToSavedPhotosAlbum return the saved video path?

查看:622
本文介绍了IOS -how可以UISaveVideoAtPathToSavedPhotosAlbum返回保存的视频路径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

- (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来保存录制的视频。我想知道专辑中我保存录制视频的绝对路径。

I use UISaveVideoAtPathToSavedPhotosAlbum to save video recorded. And I want to know the absolute path in the album where I saved the recorded video.

我怎样才能获得保存的路径? UISaveVideoAtPathToSavedPhotosAlbum不返回任何。

How could I get the saved Path? UISaveVideoAtPathToSavedPhotosAlbum does not return any.

并且在回调函数video:didFinishSavingWithError:contextInfo:仍然没有路径信息。

and in the callback function video:didFinishSavingWithError:contextInfo: there is still not path info.

推荐答案

据我所知..您无法获取相册中保存的视频的路径。如果您希望从您的应用中重播文件列表。您可以在应用程序中包含所有视频。

As far as I know.. You cannot get the path for the videos saved in the Photo album. If you want the files list to be replayed from your app. You can have all the videos inside your application.

以下是放入didFinishPickingMedia的示例代码,用于将视频存储在旁边文档中。这样您就可以跟踪它。

Following is your sample code to put inside didFinishPickingMedia to store the videos in side documents.. So that you can keep track of it.

   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];

希望这可以帮助你..

Hope this helps you..

这篇关于IOS -how可以UISaveVideoAtPathToSavedPhotosAlbum返回保存的视频路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆