2013-08-27 85 views

回答

0

您可以保存使用UISaveVideoAtPathToSavedPhotosAlbum

解決方案

UISaveVideoAtPathToSavedPhotosAlbum(yourVideoPath, nil, nil, nil); 

要獲取視頻的路徑,你必須在任何地方保存。您可以保存到目標路徑。

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); 
NSString *basePath = ([paths count] > 0) ? [paths objectAtIndex:0] : nil; 
NSString * yourVideoPath = [basePath stringByAppendingPathComponent:@"video.mov"]; 

[yourVideoData writeToFile:yourFilePath atomically:YES]; 
0

你可以試試這個link ??

這將在指定路徑添加電影到用戶的相機膠捲相冊。

void UISaveVideoAtPathToSavedPhotosAlbum (
    NSString *videoPath, 
    id  completionTarget, 
    SEL  completionSelector, 
    void  *contextInfo 
); 

你會發現在我指定

進一步有用的鏈接上面的鏈接進一步指導this

希望它有助於..

2

試試這個,這是爲我工作

-(void)SaveVideoTOPhotoAlbum 
    { 
     NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); 
     NSString *basePath = ([paths count] > 0) ? [paths objectAtIndex:0] : nil; 
     NSString *getImagePath = [basePath stringByAppendingPathComponent:videoName]; 
      printf(" \n\n\n-Video file == %s--\n\n\n",[getImagePath UTF8String]); 
     UISaveVideoAtPathToSavedPhotosAlbum (getImagePath,self, @selector(video:didFinishSavingWithError: contextInfo:), nil); 
    } 

//

- (void) video: (NSString *) videoPath didFinishSavingWithError: (NSError *) error contextInfo: (void *) contextInfo 
    { 
     NSLog(@"Finished saving video with error: %@", error); 
     //kapil here **** 
    } 

祝親愛的

0

試試這個...

NSURL *videoUrl = [NSURL URLWithString:[NSString stringWithFormat:@"Your Video Url"]]; 

dispatch_queue_t q = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0ul); 
dispatch_async(q, ^{ 

NSData *videoData = [NSData dataWithContentsOfURL:videoUrl]; 

dispatch_async(dispatch_get_main_queue(), ^{ 

    // Write it to cache directory 
    NSString *videoPath = [[NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) objectAtIndex:0] stringByAppendingPathComponent:@"file.mov"]; 
    [videoData writeToFile:videoPath atomically:YES]; 

    // After that use this path to save it to PhotoLibrary 
    ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init]; 
    [library writeVideoAtPathToSavedPhotosAlbum:[NSURL fileURLWithPath:videoPath] completionBlock:^(NSURL *assetURL, NSError *error) 
    { 
     if (error) 
     { 
      NSLog("Error"); 
     } 
     else 
     { 
      NSLog("Success"); 
     } 

     }]; 
    }); 
}); 
相關問題