1
我有一個簡單的應用程序,你可以從照片庫中選擇一個現有的視頻,或者你可以用UIImagePickerController拍攝一個視頻。didFinishPickingMediaWithInfo保存時重複文件
我添加了下面的代碼,當我用相機制作新視頻時,如果將來需要,我可以將它保存在相冊中。
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
// Get the selected Video.
NSURL *videoURL = [info objectForKey:UIImagePickerControllerMediaURL];
// Convert to Video data.
NSData *imageData = [NSData dataWithContentsOfURL:videoURL];
// Save Video to Photo Album
ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
NSURL *recordedVideoURL= [info objectForKey:UIImagePickerControllerMediaURL];
if ([library videoAtPathIsCompatibleWithSavedPhotosAlbum:recordedVideoURL]) {
[library writeVideoAtPathToSavedPhotosAlbum:recordedVideoURL
completionBlock:^(NSURL *assetURL, NSError *error){}
];
}
[library release];
[picker dismissModalViewControllerAnimated:NO];
}
現在我的問題是,當我從照片庫中選擇一個視頻時,同一個視頻被複制,因爲此代碼一直保存一個新視頻。
這是一種檢測您是否從照片庫中選擇了視頻的方法嗎?
謝謝!它工作完美... – Ben