当我 NSLog BOOL 成功 = [videoDataDecrypted writeToFile:videopath atomically:NO]; 这个声明它总是显示否
- (void) imagePickerController: (UIImagePickerController *) picker
didFinishPickingMediaWithInfo: (NSDictionary *) info {
NSString *mediaType = [info objectForKey: UIImagePickerControllerMediaType];
picker.allowsEditing = NO;
[self dismissModalViewControllerAnimated:NO];
// Handle a movie capture
if (CFStringCompare ((__bridge_retained CFStringRef)mediaType, kUTTypeMovie, 0)
== kCFCompareEqualTo)
{
NSString *moviePath = [[info objectForKey:
UIImagePickerControllerMediaURL] path];
NSURL *movieURL1 = [NSURL URLWithString:moviePath];
NSLog(@"moviePath %@",moviePath);
NSData *videoDataEncrypted = [NSData dataWithContentsOfURL:movieURL1];
[videoDataEncrypted AES256EncryptWithKey:@"123"];
NSData *videoDataDecrypted = [videoDataDecrypted AES256DecryptWithKey:@"123"];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,
NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setDateFormat:@"dd-MM-yyyy HH:mm:SS"];
NSDate *now = [[NSDate alloc] init];
NSString *theDate = [dateFormat stringFromDate:now];
NSString *dataPath = [documentsDirectory stringByAppendingPathComponent:@"Default Album"];
if (![[NSFileManager defaultManager] fileExistsAtPath:dataPath])
[[NSFileManager defaultManager] createDirectoryAtPath:dataPath
withIntermediateDirectories:NO
attributes:nil
error:nil];
NSString *videopath= [[NSString alloc] initWithString:[NSString
stringWithFormat:@"%@/%@.mov",documentsDirectory,theDate]];
BOOL success = [videoDataDecrypted writeToFile:videopath atomically:NO];
NSLog(@"Successs:::: %@", success ? @"YES" : @"NO");
NSLog(@"video path --> %@",videopath);
NSString* urlTextEscaped = [videopath
stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSURL *movieUrl2 = [NSURL fileURLWithPath:urlTextEscaped];
UIGraphicsBeginImageContext(CGSizeMake(1,1));
MPMoviePlayerViewController* theMovie =
[[MPMoviePlayerViewController alloc] initWithContentURL: movieUrl2];
UIGraphicsEndImageContext();
[self presentMoviePlayerViewControllerAnimated:theMovie];
// Register for the playback finished notification
[[NSNotificationCenter defaultCenter]
addObserver: self
selector: @selector(myMovieFinishedCallback:)
name: MPMoviePlayerPlaybackDidFinishNotification
object: theMovie];
}
}