From c24b41c69846727f0c4907949a60df77dcd33596 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Tue, 17 Apr 2012 00:00:21 -0400 Subject: Media/Video Library selector: * button to open popover * Popover displays a videos from saved Photos library, allows user to select one. --- Video Tuneup.xcodeproj/project.pbxproj | 2 + Video Tuneup/ViewController.h | 5 ++ Video Tuneup/ViewController.m | 16 ++++- Video Tuneup/en.lproj/ViewController_iPad.xib | 90 +++++++++++++++++++++------ 4 files changed, 92 insertions(+), 21 deletions(-) diff --git a/Video Tuneup.xcodeproj/project.pbxproj b/Video Tuneup.xcodeproj/project.pbxproj index 6b9e579..e302a2a 100644 --- a/Video Tuneup.xcodeproj/project.pbxproj +++ b/Video Tuneup.xcodeproj/project.pbxproj @@ -461,6 +461,7 @@ GCC_PREFIX_HEADER = "Video Tuneup/Video Tuneup-Prefix.pch"; INFOPLIST_FILE = "Video Tuneup/Video Tuneup-Info.plist"; PRODUCT_NAME = "$(TARGET_NAME)"; + TARGETED_DEVICE_FAMILY = "1,2"; WRAPPER_EXTENSION = app; }; name = Debug; @@ -472,6 +473,7 @@ GCC_PREFIX_HEADER = "Video Tuneup/Video Tuneup-Prefix.pch"; INFOPLIST_FILE = "Video Tuneup/Video Tuneup-Info.plist"; PRODUCT_NAME = "$(TARGET_NAME)"; + TARGETED_DEVICE_FAMILY = "1,2"; WRAPPER_EXTENSION = app; }; name = Release; diff --git a/Video Tuneup/ViewController.h b/Video Tuneup/ViewController.h index 8c84b4f..fb2f19a 100644 --- a/Video Tuneup/ViewController.h +++ b/Video Tuneup/ViewController.h @@ -34,6 +34,9 @@ @property (nonatomic, retain) IBOutlet UILabel *exportStatus; @property (nonatomic, retain) IBOutlet UISlider* mScrubber; +@property (nonatomic, retain) IBOutlet UIButton *mediaLibraryButton; +@property (nonatomic, retain) UIPopoverController *mediaLibraryPopover; + - (void)hideCameraRollText; - (IBAction)loadAssetFromFile:sender; @@ -52,4 +55,6 @@ - (CMTime)playerItemDuration; - (void)exportDidFinish:(AVAssetExportSession*)session; + +- (IBAction)showMediaLibrary:(id)sender; @end \ No newline at end of file diff --git a/Video Tuneup/ViewController.m b/Video Tuneup/ViewController.m index 83a82a9..e26af47 100644 --- a/Video Tuneup/ViewController.m +++ b/Video Tuneup/ViewController.m @@ -16,7 +16,7 @@ static const NSString *ItemStatusContext; @implementation ViewController @synthesize player, playerItem, playerView, playButton, pauseButton, rewindButton, editor, videoNavBar, exportStatus, -mScrubber; +mScrubber, mediaLibraryButton, mediaLibraryPopover; #pragma mark - Video playback @@ -398,6 +398,20 @@ mScrubber; [player play]; // loop player. If not doing this, set button to pause } +#pragma mark - Media Library + +- (IBAction)showMediaLibrary:(id)sender { + // http://stackoverflow.com/questions/2469523/mpmediapickercontroller-for-selecting-video-files#answer-3212470 + + UIButton *theButton = (UIButton *)sender; + UIImagePickerController* picker = [[UIImagePickerController alloc] init]; + //picker.delegate = self; + picker.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum; + picker.mediaTypes = [UIImagePickerController availableMediaTypesForSourceType:picker.sourceType]; + mediaLibraryPopover = [[UIPopoverController alloc] initWithContentViewController:picker]; + [self.mediaLibraryPopover presentPopoverFromRect:[theButton bounds] inView:theButton permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES]; + +} #pragma mark - View controller boilerplate diff --git a/Video Tuneup/en.lproj/ViewController_iPad.xib b/Video Tuneup/en.lproj/ViewController_iPad.xib index d4cece4..17a4421 100644 --- a/Video Tuneup/en.lproj/ViewController_iPad.xib +++ b/Video Tuneup/en.lproj/ViewController_iPad.xib @@ -2,10 +2,10 @@ 1280 - 11D50d + 10K549 1938 - 1138.32 - 568.00 + 1038.36 + 461.00 com.apple.InterfaceBuilder.IBCocoaTouchPlugin 933 @@ -46,7 +46,6 @@ - _NS:241 NO IBIPadFramework 0 @@ -82,7 +81,6 @@ - _NS:241 NO IBIPadFramework 0 @@ -112,7 +110,7 @@ {{93, 11}, {564, 23}} - + NO IBIPadFramework 0 @@ -168,7 +166,6 @@ - _NS:212 1 MCAwIDAAA @@ -185,7 +182,6 @@ - _NS:241 NO IBIPadFramework 0 @@ -215,7 +211,6 @@ - _NS:345 NO YES 7 @@ -237,6 +232,35 @@ 16 + + + 292 + {{54, 906}, {75, 37}} + + + + NO + IBIPadFramework + 0 + 0 + 1 + Library + + + 1 + MC4xOTYwNzg0MzQ2IDAuMzA5ODAzOTMyOSAwLjUyMTU2ODY1NgA + + + + 2 + 15 + + + Helvetica-Bold + 15 + 16 + + {{0, 20}, {768, 1004}} @@ -258,7 +282,6 @@ 292 {72, 37} - _NS:241 NO IBIPadFramework 0 @@ -271,15 +294,8 @@ MC4xOTYwNzg0MzQ2IDAuMzA5ODAzOTMyOSAwLjUyMTU2ODY1NgA - - 2 - 15 - - - Helvetica-Bold - 15 - 16 - + + @@ -324,6 +340,14 @@ 51 + + + mediaLibraryButton + + + + 60 + loadAssetFromFile: @@ -403,6 +427,15 @@ 46 + + + showMediaLibrary: + + + 7 + + 61 + @@ -432,6 +465,7 @@ + @@ -519,6 +553,11 @@ + + 59 + + + @@ -540,6 +579,7 @@ com.apple.InterfaceBuilder.IBCocoaTouchPlugin com.apple.InterfaceBuilder.IBCocoaTouchPlugin com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin PlayerView com.apple.InterfaceBuilder.IBCocoaTouchPlugin @@ -547,7 +587,7 @@ - 58 + 61 @@ -569,6 +609,7 @@ id id id + id @@ -595,10 +636,15 @@ rewind: id + + showMediaLibrary: + id + UILabel UISlider + UIButton UIButton UIButton PlayerView @@ -614,6 +660,10 @@ mScrubber UISlider + + mediaLibraryButton + UIButton + pauseButton UIButton -- cgit v1.2.3