aboutsummaryrefslogtreecommitdiffstats
path: root/Video Tuneup/ViewController.m
diff options
context:
space:
mode:
authorBrian Jordan2012-04-25 23:42:43 -0400
committerBrian Jordan2012-04-25 23:42:43 -0400
commit3c243aeaba4540732f820ec5d88c7cca3277bc5e (patch)
treea965ba6eb500b830a6ae0980310d3bc700cef7f6 /Video Tuneup/ViewController.m
parente9463eded67de701f9c3b9d0d794ca09ca913d75 (diff)
downloadVideo-Tuneup-3c243aeaba4540732f820ec5d88c7cca3277bc5e.tar.bz2
load video from library. Resolves Issue #19
Diffstat (limited to 'Video Tuneup/ViewController.m')
-rw-r--r--Video Tuneup/ViewController.m62
1 files changed, 34 insertions, 28 deletions
diff --git a/Video Tuneup/ViewController.m b/Video Tuneup/ViewController.m
index da1616c..6637c9d 100644
--- a/Video Tuneup/ViewController.m
+++ b/Video Tuneup/ViewController.m
@@ -67,40 +67,45 @@ mScrubber, mediaLibraryButton, mediaLibraryPopover;
[self play:nil];
}
-- (IBAction)loadAssetFromFile:sender {
- NSLog(@"Loading asset.");
-
- NSURL *fileURL = [[NSBundle mainBundle]
- URLForResource:@"sample_iPod" withExtension:@"m4v"];
+- (void)loadAssetFromFile:(NSURL*)fileURL {
asset = [AVURLAsset URLAssetWithURL:fileURL options:nil];
- NSLog(@"Asset duration is %f", CMTimeGetSeconds([asset duration]));
-
- NSString *tracksKey = @"tracks";
+ NSLog(@"Asset duration is %f", CMTimeGetSeconds([asset duration]));
- [asset loadValuesAsynchronouslyForKeys:[NSArray arrayWithObject:tracksKey] completionHandler:
- ^{
- NSLog(@"Handler block reached");
- // Completion handler block.
- dispatch_async(dispatch_get_main_queue(),
- ^{
- NSError *error = nil;
- AVKeyValueStatus status = [asset statusOfValueForKey:tracksKey error:&error];
+ NSString *tracksKey = @"tracks";
- if (status == AVKeyValueStatusLoaded) {
- [self refreshEditor];
+ [asset loadValuesAsynchronouslyForKeys:[NSArray arrayWithObject:tracksKey] completionHandler:
+ ^{
+ NSLog(@"Handler block reached");
+ // Completion handler block.
+ dispatch_async(dispatch_get_main_queue(),
+ ^{
+ NSError *error = nil;
+ AVKeyValueStatus status = [asset statusOfValueForKey:tracksKey error:&error];
+
+ if (status == AVKeyValueStatusLoaded) {
+ [self refreshEditor];
+
+ // File has loaded into player
+ NSLog(@"File loaded!");
+ NSLog(@"Asset duration is %f", CMTimeGetSeconds([asset duration]));
+
+ }
+ else {
+ // You should deal with the error appropriately.
+ NSLog(@"The asset's tracks were not loaded:\n%@", [error localizedDescription]);
+ }
+ });
+ }];
+}
+
+- (IBAction)loadDefaultAssetFromFile:sender {
+ NSLog(@"Loading asset.");
- // File has loaded into player
- NSLog(@"File loaded!");
- NSLog(@"Asset duration is %f", CMTimeGetSeconds([asset duration]));
+ NSURL *fileURL = [[NSBundle mainBundle]
+ URLForResource:@"sample_iPod" withExtension:@"m4v"];
- }
- else {
- // You should deal with the error appropriately.
- NSLog(@"The asset's tracks were not loaded:\n%@", [error localizedDescription]);
- }
- });
- }];
+ [self loadAssetFromFile:fileURL];
}
- (IBAction)loadAudioFromFile:(id)sender {
@@ -441,6 +446,7 @@ mScrubber, mediaLibraryButton, mediaLibraryPopover;
UIButton *theButton = (UIButton *)sender;
AssetsViewController *avc = [[AssetsViewController alloc] initWithStyle:UITableViewStylePlain];
+ [avc setParentViewController:self];
mediaLibraryPopover = [[UIPopoverController alloc] initWithContentViewController:avc];
// [mediaLibraryPopover setPopoverContentSize:<#(CGSize)#>// Change size of popover so that it doesn't take up the whole height