0
내가 내가 저장해야이 코드 비디오를 다운로드하고 라이브러리의 맞춤 앨범에 저장 하시겠습니까?
-(IBAction)btnDownload:(UIView *)sender { [DSBezelActivityView newActivityViewForView:self.view withLabel:@"DOWNLOADING..."]; NSString *[email protected]"album name"; NSURL *url = [NSURL URLWithString:@"http://www.ebookfrenzy.com/ios_book/movie/movie.mov"]; ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url]; [request setDelegate:self]; [request setDownloadDestinationPath:@"/Users/seemtech/Desktop/dd/vvv.m4v"];//work fine [ASIHTTPRequest setDefaultTimeOutSeconds:3000]; [request startAsynchronous]; } failureBlock:^(NSError *error) { NSLog(@"error adding album"); }]; } -(void)requestFinished:(ASIHTTPRequest *)request { [[[[UIAlertView alloc] initWithTitle:@"Message" message:@"Success!!!" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil] autorelease] show]; [DSBezelActivityView removeViewAnimated:YES]; } -(void)requestFailed:(ASIHTTPRequest *)request { NSLog(@"error==%@",request.error); [DSBezelActivityView removeViewAnimated:YES]; }
를 사용하여 서버에서 비디오를 다운로드해야
NSString *[email protected]"iphonemaclover";
ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
[library addAssetsGroupAlbumWithName:albumName
resultBlock:^(ALAssetsGroup *group) {
NSLog(@"added album:%@", albumName);
및 이 코드를 사용하여 내 사진 라이브러리에서 앨범을 만들었습니다 내가 만든 앨범의 비디오. 어떻게 할 수 있습니까?
ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
NSURL *capturedVideoURL = [NSURL URLWithString:@"/Users/seemtech/Desktop/dd/vvv.m4v"];
if ([library videoAtPathIsCompatibleWithSavedPhotosAlbum:capturedVideoURL]) {
// request to save video in photo roll.
[library writeVideoAtPathToSavedPhotosAlbum:capturedVideoURL completionBlock:^(NSURL *assetURL, NSError *error) {
if (error) {
NSLog(@"error while saving video");
} else{
[self addAssetURL:assetURL toAlbum:@"iphonemaclover"];
}
}];
}
이 코드를 사용하여 앨범에
- (void)addAssetURL:(NSURL*)assetURL toAlbum:(NSString*)albumName
{
ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
[library enumerateGroupsWithTypes:ALAssetsGroupAlbum usingBlock:^(ALAssetsGroup *group, BOOL *stop) {
if ([albumName compare: [group valueForProperty:ALAssetsGroupPropertyName]]==NSOrderedSame) {
//If album found
[library assetForURL:assetURL resultBlock:^(ALAsset *asset) {
//add asset to album
[group addAsset:asset];
} failureBlock:nil];
}
else {
//if album not found create an album
[library addAssetsGroupAlbumWithName:albumName resultBlock:^(ALAssetsGroup *group) {
[self addAssetURL:assetURL toAlbum:albumName];
} failureBlock:nil];
}
} failureBlock: nil];
}
유일한 문제를 그 자산을 추가