diff --git a/DBCamera/Controllers/DBCameraCollectionViewController.m b/DBCamera/Controllers/DBCameraCollectionViewController.m index 7293423..31cebc9 100644 --- a/DBCamera/Controllers/DBCameraCollectionViewController.m +++ b/DBCamera/Controllers/DBCameraCollectionViewController.m @@ -66,12 +66,31 @@ - (UICollectionViewCell *) collectionView:(UICollectionView *)collectionView cel { DBCollectionViewCell *item = [collectionView dequeueReusableCellWithReuseIdentifier:_collectionIdentifier forIndexPath:indexPath]; [item.itemImage setImage:nil]; + [item.itemDuration setText:nil]; + item.itemDuration.hidden = YES; if ( _items.count > 0) { __weak DBCollectionViewCell *blockItem = item; [[[DBLibraryManager sharedInstance] defaultAssetsLibrary] assetForURL:(NSURL *)_items[indexPath.item] resultBlock:^(ALAsset *asset) { UIImage *image = [UIImage imageWithCGImage:[asset thumbnail]]; [blockItem.itemImage setImage:image]; + NSString *assetPropertyType = [asset valueForProperty:ALAssetPropertyType]; + if ([assetPropertyType isEqualToString:ALAssetTypeVideo]) { + blockItem.itemDuration.hidden = NO; + double value = [[asset valueForProperty:ALAssetPropertyDuration] doubleValue]; + + NSNumber *theDouble = [NSNumber numberWithDouble:round(value)]; + + int inputSeconds = [theDouble intValue]; + int hours = inputSeconds / 3600; + int minutes = ( inputSeconds - hours * 3600 ) / 60; + int seconds = inputSeconds - hours * 3600 - minutes * 60; + + NSString *theTime = [NSString stringWithFormat:@"%.2d:%.2d:%.2d", hours, minutes, seconds]; + + blockItem.itemDuration.text = theTime; + } + } failureBlock:nil]; } diff --git a/DBCamera/Controllers/DBCameraLibraryViewController.m b/DBCamera/Controllers/DBCameraLibraryViewController.m index 12db823..8cba064 100644 --- a/DBCamera/Controllers/DBCameraLibraryViewController.m +++ b/DBCamera/Controllers/DBCameraLibraryViewController.m @@ -11,6 +11,7 @@ #import "DBCollectionViewCell.h" #import "DBCollectionViewFlowLayout.h" #import "DBCameraSegueViewController.h" +#import "DBCameraVideoSegueViewController.h" #import "DBCameraCollectionViewController.h" #import "DBCameraMacros.h" #import "DBCameraLoadingView.h" @@ -340,22 +341,38 @@ - (void) collectionView:(UICollectionView *)collectionView itemURL:(NSURL *)URL UIImage *image = [UIImage imageForAsset:asset maxPixelSize:_libraryMaxImageSize]; - if ( !weakSelf.useCameraSegue ) { - if ( [weakSelf.delegate respondsToSelector:@selector(camera:didFinishWithImage:withMetadata:)] ) - [weakSelf.delegate camera:self didFinishWithImage:image withMetadata:metadata]; - } else { - DBCameraSegueViewController *segue = [[DBCameraSegueViewController alloc] initWithImage:image thumb:[UIImage imageWithCGImage:[asset aspectRatioThumbnail]]]; - [segue setTintColor:self.tintColor]; - [segue setSelectedTintColor:self.selectedTintColor]; - [segue setForceQuadCrop:_forceQuadCrop]; - [segue enableGestures:YES]; - [segue setCapturedImageMetadata:metadata]; - [segue setDelegate:weakSelf.delegate]; - [segue setCameraSegueConfigureBlock:self.cameraSegueConfigureBlock]; + NSString *assetPropertyType = [asset valueForProperty:ALAssetPropertyType]; + if ([assetPropertyType isEqualToString:ALAssetTypePhoto]) { + if ( !weakSelf.useCameraSegue ) { + if ( [weakSelf.delegate respondsToSelector:@selector(camera:didFinishWithImage:withMetadata:)] ) + [weakSelf.delegate camera:self didFinishWithImage:image withMetadata:metadata]; + } else { + DBCameraSegueViewController *segue = [[DBCameraSegueViewController alloc] initWithImage:image thumb:[UIImage imageWithCGImage:[asset aspectRatioThumbnail]]]; + [segue setTintColor:self.tintColor]; + [segue setSelectedTintColor:self.selectedTintColor]; + [segue setForceQuadCrop:_forceQuadCrop]; + [segue enableGestures:YES]; + [segue setCapturedImageMetadata:metadata]; + [segue setDelegate:weakSelf.delegate]; + [segue setCameraSegueConfigureBlock:self.cameraSegueConfigureBlock]; + + [weakSelf.navigationController pushViewController:segue animated:YES]; + } + + } else if ([assetPropertyType isEqualToString:ALAssetTypeVideo]) { - [weakSelf.navigationController pushViewController:segue animated:YES]; + if ( !weakSelf.useCameraSegue ) { + if ( [weakSelf.delegate respondsToSelector:@selector(camera:didFinishWithVideoALAsset:)] ) { + [weakSelf.delegate camera:self didFinishWithVideoALAsset:asset]; + } + } else { + // Video Segue Controller + DBCameraVideoSegueViewController *videoSegueViewController = [[DBCameraVideoSegueViewController alloc] initWithVideoALAsset:asset]; + [weakSelf.navigationController pushViewController:videoSegueViewController animated:YES]; + } } + [weakSelf.loading removeFromSuperview]; } failureBlock:nil]; }); diff --git a/DBCamera/Controllers/DBCameraVideoSegueViewController.h b/DBCamera/Controllers/DBCameraVideoSegueViewController.h new file mode 100644 index 0000000..46a7a57 --- /dev/null +++ b/DBCamera/Controllers/DBCameraVideoSegueViewController.h @@ -0,0 +1,19 @@ +// +// DBCameraVideoSegueViewController.h +// DBCamera +// +// Created by dw_iOS on 14-10-14. +// Copyright (c) 2014年 PSSD - Daniele Bogo. All rights reserved. +// + +#import +#import +#import + +@interface DBCameraVideoSegueViewController : UIViewController + +@property (nonatomic, strong) GPUImageMovie *imageMovie; + +- (instancetype)initWithVideoALAsset:(ALAsset *)videoAsset; + +@end diff --git a/DBCamera/Controllers/DBCameraVideoSegueViewController.m b/DBCamera/Controllers/DBCameraVideoSegueViewController.m new file mode 100644 index 0000000..83c706d --- /dev/null +++ b/DBCamera/Controllers/DBCameraVideoSegueViewController.m @@ -0,0 +1,65 @@ +// +// DBCameraVideoSegueViewController.m +// DBCamera +// +// Created by dw_iOS on 14-10-14. +// Copyright (c) 2014年 PSSD - Daniele Bogo. All rights reserved. +// + +#import "DBCameraVideoSegueViewController.h" +#import + +@interface DBCameraVideoSegueViewController () + +@property (nonatomic, strong) GPUImageView *progressImageView; +@property (nonatomic, strong) AVPlayer *player; + +@end + +@implementation DBCameraVideoSegueViewController + +- (instancetype)initWithVideoALAsset:(ALAsset *)videoAsset { + self = [super init]; + if (self) { + NSURL *URL = [[videoAsset defaultRepresentation] url]; + self.imageMovie = [[GPUImageMovie alloc] initWithURL:URL]; + self.imageMovie.runBenchmark = NO; + self.imageMovie.playAtActualSpeed = NO; + self.imageMovie.shouldRepeat = YES; + + self.player = [[AVPlayer alloc] initWithURL:URL]; + } + return self; +} + +- (void)viewDidLoad { + [super viewDidLoad]; + // Do any additional setup after loading the view. + self.view.backgroundColor = [UIColor blackColor]; + + self.progressImageView = [[GPUImageView alloc] initWithFrame:self.view.bounds]; + [self.view addSubview:self.progressImageView]; + + + GPUImageToneCurveFilter *filter = [[GPUImageToneCurveFilter alloc] initWithACV:@"amaro"]; + [self.imageMovie addTarget:filter]; + [filter addTarget:self.progressImageView]; +} + +- (void)viewDidAppear:(BOOL)animated { + [super viewDidAppear:animated]; + [self.imageMovie startProcessing]; + [self.player play]; +} + +- (void)viewWillDisappear:(BOOL)animated { + [super viewWillDisappear:animated]; + [self.imageMovie endProcessing]; +} + +- (void)didReceiveMemoryWarning { + [super didReceiveMemoryWarning]; + // Dispose of any resources that can be recreated. +} + +@end diff --git a/DBCamera/Headers/DBCameraDelegate.h b/DBCamera/Headers/DBCameraDelegate.h index 7638518..51b04a5 100644 --- a/DBCamera/Headers/DBCameraDelegate.h +++ b/DBCamera/Headers/DBCameraDelegate.h @@ -8,6 +8,8 @@ #import #import +#import + /** * DBCameraView delegate protocol */ @@ -102,6 +104,14 @@ */ - (void) camera:(id)cameraViewController didFinishWithImage:(UIImage *)image withMetadata:(NSDictionary *)metadata; +/** + * Tells the delegate when the video is ready to use + * + * @param cameraViewController The controller object managing the DBCamera interface. + * @param videoAsset The captured video asset + */ +- (void) camera:(id)cameraViewController didFinishWithVideoALAsset:(ALAsset *)videoAsset; + /** * Tells the delegate when the camera must be dismissed */ diff --git a/DBCamera/Managers/DBLibraryManager.m b/DBCamera/Managers/DBLibraryManager.m index 5a23b71..fde2f25 100644 --- a/DBCamera/Managers/DBLibraryManager.m +++ b/DBCamera/Managers/DBLibraryManager.m @@ -111,7 +111,7 @@ - (ALAssetsGroupEnumerationResultsBlock) assetsEnumerator ALAssetsGroupEnumerationResultsBlock assetsEnumerator = ^(ALAsset *result, NSUInteger index, BOOL *stop) { if ( result ) { - if( [[result valueForProperty:ALAssetPropertyType] isEqualToString:ALAssetTypePhoto] ) { + if( [[result valueForProperty:ALAssetPropertyType] isEqualToString:ALAssetTypePhoto] || [[result valueForProperty:ALAssetPropertyType] isEqualToString:ALAssetTypeVideo] ) { if ( [result defaultRepresentation] ) { [items addObject:[[result defaultRepresentation] url]]; assetResult = result; diff --git a/DBCamera/Objects/DBCollectionViewCell.h b/DBCamera/Objects/DBCollectionViewCell.h index 2dc38e8..5f113de 100644 --- a/DBCamera/Objects/DBCollectionViewCell.h +++ b/DBCamera/Objects/DBCollectionViewCell.h @@ -16,4 +16,9 @@ * The item UIImageView */ @property (nonatomic, strong) UIImageView *itemImage; + +/** + * The item Duration + */ +@property (nonatomic, strong) UILabel *itemDuration; @end \ No newline at end of file diff --git a/DBCamera/Objects/DBCollectionViewCell.m b/DBCamera/Objects/DBCollectionViewCell.m index eb0d3e1..beb65d8 100644 --- a/DBCamera/Objects/DBCollectionViewCell.m +++ b/DBCamera/Objects/DBCollectionViewCell.m @@ -16,6 +16,8 @@ - (id)initWithFrame:(CGRect)frame if (self) { // Initialization code [self.contentView addSubview:self.itemImage]; + + [self.contentView addSubview:self.itemDuration]; } return self; } @@ -32,4 +34,18 @@ - (UIImageView *) itemImage return _itemImage; } +- (UILabel *) itemDuration +{ + if( !_itemDuration ) { + CGFloat durationLabelHeight = 20; + _itemDuration = [[UILabel alloc] initWithFrame:CGRectMake(0, CGRectGetHeight(self.bounds) - durationLabelHeight, CGRectGetWidth(self.bounds), durationLabelHeight)]; + [_itemDuration setTextColor:[UIColor whiteColor]]; + [_itemDuration setBackgroundColor:[UIColor colorWithWhite:0.0 alpha:0.5]]; + [_itemDuration setTextAlignment:NSTextAlignmentRight]; + [_itemDuration setFont:[UIFont systemFontOfSize:14]]; + } + + return _itemDuration; +} + @end \ No newline at end of file diff --git a/Example/DBCamera.xcodeproj/project.pbxproj b/Example/DBCamera.xcodeproj/project.pbxproj index f60c763..d702c7e 100644 --- a/Example/DBCamera.xcodeproj/project.pbxproj +++ b/Example/DBCamera.xcodeproj/project.pbxproj @@ -24,6 +24,8 @@ 6594EE0F1955F12800E22EBD /* AVFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6594EE0E1955F12800E22EBD /* AVFoundation.framework */; }; 6594EE121955F19600E22EBD /* RootViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 6594EE111955F19600E22EBD /* RootViewController.m */; }; 733E4274497440D09A9F1EE7 /* libPods-DBCamera.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4BE3F8BFBAFD401181A3E55F /* libPods-DBCamera.a */; }; + 7DA3A4D719ECF96F006AB015 /* DBCameraVideoSegueViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 7DA3A4D619ECF96F006AB015 /* DBCameraVideoSegueViewController.m */; }; + 7DA3A4D919ED1269006AB015 /* me.mp4 in Resources */ = {isa = PBXBuildFile; fileRef = 7DA3A4D819ED1269006AB015 /* me.mp4 */; }; 9A1F4A7F191C20CB0084C305 /* UIImage+Crop.m in Sources */ = {isa = PBXBuildFile; fileRef = 9A1F4A5D191C20CB0084C305 /* UIImage+Crop.m */; }; 9A1F4A80191C20CB0084C305 /* DBCameraBaseCropViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 9A1F4A60191C20CB0084C305 /* DBCameraBaseCropViewController.m */; }; 9A1F4A81191C20CB0084C305 /* DBCameraCollectionViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 9A1F4A62191C20CB0084C305 /* DBCameraCollectionViewController.m */; }; @@ -67,6 +69,7 @@ /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ + 156CF6154F58F51D3369CF26 /* Pods-DBCamera.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-DBCamera.release.xcconfig"; path = "Pods/Target Support Files/Pods-DBCamera/Pods-DBCamera.release.xcconfig"; sourceTree = ""; }; 4BE3F8BFBAFD401181A3E55F /* libPods-DBCamera.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-DBCamera.a"; sourceTree = BUILT_PRODUCTS_DIR; }; 653E218419474DA2001433A5 /* UIViewController+UIViewController_FullScreen.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIViewController+UIViewController_FullScreen.h"; sourceTree = ""; }; 653E218519474DA2001433A5 /* UIViewController+UIViewController_FullScreen.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIViewController+UIViewController_FullScreen.m"; sourceTree = ""; }; @@ -89,6 +92,10 @@ 6594EE0E1955F12800E22EBD /* AVFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AVFoundation.framework; path = System/Library/Frameworks/AVFoundation.framework; sourceTree = SDKROOT; }; 6594EE101955F19600E22EBD /* RootViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RootViewController.h; path = Classes/Root/RootViewController.h; sourceTree = ""; }; 6594EE111955F19600E22EBD /* RootViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = RootViewController.m; path = Classes/Root/RootViewController.m; sourceTree = ""; }; + 7DA3A4D519ECF96F006AB015 /* DBCameraVideoSegueViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DBCameraVideoSegueViewController.h; sourceTree = ""; }; + 7DA3A4D619ECF96F006AB015 /* DBCameraVideoSegueViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DBCameraVideoSegueViewController.m; sourceTree = ""; }; + 7DA3A4D819ED1269006AB015 /* me.mp4 */ = {isa = PBXFileReference; lastKnownFileType = file; path = me.mp4; sourceTree = ""; }; + 949CBF1C771BF7785A762159 /* Pods-DBCamera.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-DBCamera.debug.xcconfig"; path = "Pods/Target Support Files/Pods-DBCamera/Pods-DBCamera.debug.xcconfig"; sourceTree = ""; }; 9A0FAE53193E840D008D5FAD /* pt */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = pt; path = pt.lproj/DBCamera.strings; sourceTree = ""; }; 9A0FAE54193E840D008D5FAD /* pt */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = pt; path = pt.lproj/InfoPlist.strings; sourceTree = ""; }; 9A0FAE55193E840D008D5FAD /* pt */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = pt; path = pt.lproj/InfoPlist.strings; sourceTree = ""; }; @@ -156,7 +163,6 @@ 9ABDB6E5195391A500A1539D /* tr */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = tr; path = tr.lproj/DBCamera.strings; sourceTree = ""; }; 9ABDB6E6195391A500A1539D /* tr */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = tr; path = tr.lproj/InfoPlist.strings; sourceTree = ""; }; 9ABDB6E7195391A500A1539D /* tr */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = tr; path = tr.lproj/InfoPlist.strings; sourceTree = ""; }; - BF04884E51D24925BF79CD2E /* Pods-DBCamera.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-DBCamera.xcconfig"; path = "Pods/Pods-DBCamera.xcconfig"; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -221,6 +227,15 @@ name = Classes; sourceTree = ""; }; + 85499B0308E04BB80F02A92C /* Pods */ = { + isa = PBXGroup; + children = ( + 949CBF1C771BF7785A762159 /* Pods-DBCamera.debug.xcconfig */, + 156CF6154F58F51D3369CF26 /* Pods-DBCamera.release.xcconfig */, + ); + name = Pods; + sourceTree = ""; + }; 9A1F4A5A191C20CB0084C305 /* Categories */ = { isa = PBXGroup; children = ( @@ -251,6 +266,8 @@ 9A1F4A66191C20CB0084C305 /* DBCameraLibraryViewController.m */, 9A1F4A67191C20CB0084C305 /* DBCameraSegueViewController.h */, 9A1F4A68191C20CB0084C305 /* DBCameraSegueViewController.m */, + 7DA3A4D519ECF96F006AB015 /* DBCameraVideoSegueViewController.h */, + 7DA3A4D619ECF96F006AB015 /* DBCameraVideoSegueViewController.m */, 9A1F4A69191C20CB0084C305 /* DBCameraViewController.h */, 9A1F4A6A191C20CB0084C305 /* DBCameraViewController.m */, ); @@ -338,7 +355,7 @@ 9AB597C2189BAF9A001BCAD3 /* DBCameraTests */, 9AB597A2189BAF9A001BCAD3 /* Frameworks */, 9AB597A1189BAF9A001BCAD3 /* Products */, - BF04884E51D24925BF79CD2E /* Pods-DBCamera.xcconfig */, + 85499B0308E04BB80F02A92C /* Pods */, ); sourceTree = ""; }; @@ -371,6 +388,7 @@ children = ( 9AB597B2189BAF9A001BCAD3 /* AppDelegate.h */, 9AB597B3189BAF9A001BCAD3 /* AppDelegate.m */, + 7DA3A4D819ED1269006AB015 /* me.mp4 */, 655AA2D41956DB860017C143 /* Classes */, 9AB597D2189BB04B001BCAD3 /* DBCamera */, 9AB597AA189BAF9A001BCAD3 /* Supporting Files */, @@ -511,6 +529,7 @@ 655AA2CE195602340017C143 /* Nashville.acv in Resources */, 9AB597AE189BAF9A001BCAD3 /* InfoPlist.strings in Resources */, 655AA2CB195602340017C143 /* amaro.acv in Resources */, + 7DA3A4D919ED1269006AB015 /* me.mp4 in Resources */, 655AA2CD195602340017C143 /* mayfair.acv in Resources */, 655AA2CC195602340017C143 /* Hudson.acv in Resources */, 655AA2CF195602340017C143 /* Valencia.acv in Resources */, @@ -555,7 +574,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Pods-DBCamera-resources.sh\"\n"; + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-DBCamera/Pods-DBCamera-resources.sh\"\n"; showEnvVarsInLog = 0; }; /* End PBXShellScriptBuildPhase section */ @@ -590,6 +609,7 @@ 6594EC041955D94E00E22EBD /* DBCameraFiltersView.m in Sources */, 9A1F4A82191C20CB0084C305 /* DBCameraContainerViewController.m in Sources */, 9A71D2ED1958402A00224B82 /* DBCameraFilterCell.m in Sources */, + 7DA3A4D719ECF96F006AB015 /* DBCameraVideoSegueViewController.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -733,18 +753,18 @@ }; 9AB597CD189BAF9A001BCAD3 /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = BF04884E51D24925BF79CD2E /* Pods-DBCamera.xcconfig */; + baseConfigurationReference = 949CBF1C771BF7785A762159 /* Pods-DBCamera.debug.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; - CODE_SIGN_IDENTITY = ""; - "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + CODE_SIGN_IDENTITY = "iPhone Developer: 宪华 zeng (GZ6E8YQ54Z)"; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer: 宪华 zeng (GZ6E8YQ54Z)"; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "DBCamera/DBCamera-Prefix.pch"; INFOPLIST_FILE = "$(SRCROOT)/DBCamera/DBCamera-Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 6.0; PRODUCT_NAME = "$(TARGET_NAME)"; - PROVISIONING_PROFILE = ""; + PROVISIONING_PROFILE = "E5FA67B9-CB93-4572-BDA3-B7AFABED44CD"; TARGETED_DEVICE_FAMILY = 1; WRAPPER_EXTENSION = app; }; @@ -752,7 +772,7 @@ }; 9AB597CE189BAF9A001BCAD3 /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = BF04884E51D24925BF79CD2E /* Pods-DBCamera.xcconfig */; + baseConfigurationReference = 156CF6154F58F51D3369CF26 /* Pods-DBCamera.release.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; @@ -763,7 +783,7 @@ INFOPLIST_FILE = "$(SRCROOT)/DBCamera/DBCamera-Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 6.0; PRODUCT_NAME = "$(TARGET_NAME)"; - PROVISIONING_PROFILE = ""; + PROVISIONING_PROFILE = "E5FA67B9-CB93-4572-BDA3-B7AFABED44CD"; TARGETED_DEVICE_FAMILY = 1; WRAPPER_EXTENSION = app; }; diff --git a/Example/DBCamera/Classes/Root/RootViewController.m b/Example/DBCamera/Classes/Root/RootViewController.m index 9363ed2..467a04b 100644 --- a/Example/DBCamera/Classes/Root/RootViewController.m +++ b/Example/DBCamera/Classes/Root/RootViewController.m @@ -12,6 +12,7 @@ #import "DBCameraLibraryViewController.h" #import "CustomCamera.h" #import "DBCameraGridView.h" +#import @interface DetailViewController : UIViewController { UIImageView *_imageView; @@ -54,6 +55,57 @@ - (void) viewDidDisappear:(BOOL)animated @end +@interface VideoDetailViewController : UIViewController { + +} + +@property (nonatomic, strong) NSURL *videoURL; + +@property (nonatomic, strong) MPMoviePlayerController *moviePlayerController; + +@end + +@implementation VideoDetailViewController + +- (MPMoviePlayerController *)moviePlayerController { + if (!_moviePlayerController) { + _moviePlayerController = [[MPMoviePlayerController alloc] initWithContentURL:self.videoURL]; + _moviePlayerController.repeatMode = MPMovieRepeatModeOne; + _moviePlayerController.scalingMode = MPMovieScalingModeAspectFill; + _moviePlayerController.view.frame = self.view.frame; + } + return _moviePlayerController; +} + +- (void) viewDidLoad +{ + [super viewDidLoad]; + +#if __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_7_0 + [self setEdgesForExtendedLayout:UIRectEdgeNone]; +#endif + + [self.navigationItem setTitle:@"VideoDetail"]; + + [self.view addSubview:self.moviePlayerController.view]; +} + +- (void) viewWillAppear:(BOOL)animated +{ + [super viewWillAppear:animated]; + [self.moviePlayerController play]; +} + +- (void) viewWillDisappear:(BOOL)animated +{ + [super viewWillDisappear:animated]; + + [_moviePlayerController stop]; + _moviePlayerController = nil; +} + +@end + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -249,4 +301,12 @@ - (void) camera:(id)cameraViewController didFinishWithImage:(UIImage *)image wit [self.presentedViewController dismissViewControllerAnimated:YES completion:nil]; } +- (void) camera:(id)cameraViewController didFinishWithVideoALAsset:(ALAsset *)videoAsset { + VideoDetailViewController *detail = [[VideoDetailViewController alloc] init]; + detail.videoURL = [[videoAsset defaultRepresentation] url]; + [self.navigationController pushViewController:detail animated:NO]; + [cameraViewController restoreFullScreenMode]; + [self.presentedViewController dismissViewControllerAnimated:YES completion:nil]; +} + @end \ No newline at end of file diff --git a/Example/DBCamera/DBCamera-Info.plist b/Example/DBCamera/DBCamera-Info.plist index 58aca3c..40599b7 100644 --- a/Example/DBCamera/DBCamera-Info.plist +++ b/Example/DBCamera/DBCamera-Info.plist @@ -13,7 +13,7 @@ CFBundleIcons~ipad CFBundleIdentifier - com.pssd.${PRODUCT_NAME:rfc1034identifier} + com.HUAJIE.$(PRODUCT_NAME:rfc1034identifier) CFBundleInfoDictionaryVersion 6.0 CFBundleName diff --git a/Example/DBCamera/me.mp4 b/Example/DBCamera/me.mp4 new file mode 100755 index 0000000..165bade Binary files /dev/null and b/Example/DBCamera/me.mp4 differ