在开发用到视频时,模拟器中往往没有视频可用,下面的方法可以把工程中得视频导入到模拟器中
- (void)saveAction
{
NSMutableArray *videoArray = [NSMutableArray arrayWithCapacity:3];
NSArray *movs = [[NSBundle mainBundle] pathsForResourcesOfType:@"mov" inDirectory:nil];
[videoArray addObjectsFromArray:movs];
// save video to camera roll
for (id item in videoArray) {
if (UIVideoAtPathIsCompatibleWithSavedPhotosAlbum(item)) {
// Note:save to camera roll is async, so the later item may copy complete than previous item
UISaveVideoAtPathToSavedPhotosAlbum(item, self, nil, NULL);
}
}
}
获取相册中得视频
#import <AssetsLibrary/AssetsLibrary.h>
- (void)addMovie
{
UIImagePickerController *moviePicker = [[UIImagePickerController alloc] init];
moviePicker.delegate = self;
moviePicker.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
moviePicker.allowsEditing = YES;
moviePicker.mediaTypes = [[NSArray alloc] initWithObjects:(NSString *)kUTTypeMovie, nil];