2014-09-03 4 views
-1

내 사용자 지정 앨범으로 비디오를 저장하는 방법. 하나의 링크를 찾았지만 작동하지 않습니다. Custom file manager사용자 지정 앨범에 비디오 저장 iOS

URL 값이 null입니다.

[VideoAlbumManager addVideoWithAssetURL:outputFileUrl toAlbumWithName:@"Video Maker"];//outputfileurl is my video url from document directory 

이것에 대한 어떤 제안을주고 .. 당신은 그것으로 시도 할 수

+0

이 링크 확인 http://stackoverflow.com/questions/17569505/saving-video-in-an-album-created 또한이 링크를 확인하십시오. http://stackoverflow.com/questions/10610708/ios-create- 사진 - 앨범 - 인 - 사진 - addassetsgroupalbumwithname - under - ios - 5 –

+0

나는 그 두 링크를 10 번 이상 확인하지만 아무것도 찾지 못했습니다. 귀하의 메일 ID로 메일을 보냅니다. –

+0

그것을 확인하고 알려주십시오. –

답변

1

당신은 비디오를 저장하려면이 링크를 사용할 수 ALAssetsLibrary에 대한 객체를 생성 그냥 같이, 사용자 정의 앨범의 비디오 파일을 저장하기위한 블록 쓰기 GitHub Link

이 두 파일을 프로젝트로 가져옵니다.

  1. ALAssetsLibrary는
  2. 이 ALAssetsLibrary + CustomPhotoAlbum.m하여 저장 IBAction를 방법에서 다음

이 줄을 쓰기 ..

if(UIVideoAtPathIsCompatibleWithSavedPhotosAlbum(outputFilePath)){ 

    NSURL *muyrl=[NSURL fileURLWithPath:outputFilePath]; 
    [library saveVideo:muyrl toAlbum:albumName withCompletionBlock:^(NSError *error) 
    { 
     if (error!=nil) { 
      NSLog(@"Big error: %@", [error description]); 
     } 
    }]; 

.. outputfilepath이 CustomPhotoAlbum.h입니다 + 귀하의 동영상 및 URL이 있으면 URL 이름으로 저장하십시오. 라이브러리은 .h 파일에서 정의하는 ALAssetLibrary입니다. albumName은 앨범 이름입니다.이게 도움이되기를 바랍니다.

2
-(void)SaveToalbum{ 
NSString *finalFileName=[NSString stringWithFormat:@"Documents/video.mov"]; 
NSString *videoOutputPath = [NSHomeDirectory() 
          stringByAppendingPathComponent:finalFileName]; 

NSString* webStringURL = [videoOutputPath stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; 
NSURL* url =[NSURL URLWithString:webStringURL]; 

ALAssetsLibrary* library = [[ALAssetsLibrary alloc]init]; 
if ([library videoAtPathIsCompatibleWithSavedPhotosAlbum:url]) 
{ 
    NSURL *clipURl = url; 
    [library writeVideoAtPathToSavedPhotosAlbum:clipURl completionBlock:^(NSURL *assetURL, NSError *error) 
    { 

    }]; 

} 

} 

합니다. 그것은 당신에게 도움이 될 것입니다. "http://www.touch-code-magazine.com/ios5-saving-photos-in-custom-photo-album-category-for-download/"링크를 통해 샘플 프로젝트를 다운로드하십시오.

  1. 드래그 앤 드롭이 개 파일 "ALAssetsLibrary+CustomPhotoAlbum.h"하고 프로젝트에 "ALAssetsLibrary+CustomPhotoAlbum.m""AssetsLibrary.framework"를 추가합니다. 이제 코딩 준비가되었습니다. ViewController.h 클래스로 이동하여 <AssetsLibrary/AssetsLibrary.h>"ALAssetsLibrary+CustomPhotoAlbum.h" 파일을 가져옵니다.
  2. ..
[ALAssetsLibraryObject addAssetURL:clipURl toAlbum:AlbumName withCompletionBlock:^(NSError *error) 
{ 
    if (error!=nil) { 
     NSLog(@"Big error: %@", [error description]) 
    } 
}]; 
관련 문제