2012-06-07 11 views
5
- (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を使用して、録画した動画を保存します。そして、私は記録されたビデオを保存したアルバムの絶対パスを知りたい。IOS - UISaveVideoAtPathToSavedPhotosAlbumが保存されたビデオパスを返すことはできますか?

保存されたパスはどのように取得できますか? UISaveVideoAtPathToSavedPhotosAlbumは何も返しません。

およびコールバック関数video:didFinishSavingWithError:contextInfo:まだパス情報がありません。

答えて

2

私が知る限り、フォトアルバムに保存されているビデオのパスを取得することはできません。あなたのアプリからファイルリストを再生したい場合。アプリケーション内にすべてのビデオを置くことができます。

次は、didFinishPickingMediaの内部に配置してサイド・ドキュメントにビデオを保存するサンプル・コードです。これを追跡することができます。これはあなたを助け

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

・ホープ..

関連する問題