cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From shaz...@apache.org
Subject ios commit: Fixed deprecated [AVAsset naturalSize] usage in Capture API (getFormatData)
Date Mon, 19 Nov 2012 19:58:48 GMT
Updated Branches:
  refs/heads/master 9c836fbf0 -> 7e6946daa


Fixed deprecated [AVAsset naturalSize] usage in Capture API (getFormatData)


Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/commit/7e6946da
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/tree/7e6946da
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/diff/7e6946da

Branch: refs/heads/master
Commit: 7e6946daa0c1e90e704a57b8a89a1d0a9c70b57f
Parents: 9c836fb
Author: Shazron Abdullah <shazron@apache.org>
Authored: Mon Nov 19 11:57:07 2012 -0800
Committer: Shazron Abdullah <shazron@apache.org>
Committed: Mon Nov 19 11:58:46 2012 -0800

----------------------------------------------------------------------
 CordovaLib/Classes/CDVCapture.m |   46 ++++++++++++++++++++-------------
 1 files changed, 28 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/7e6946da/CordovaLib/Classes/CDVCapture.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVCapture.m b/CordovaLib/Classes/CDVCapture.m
index 07eae1f..7564ce9 100644
--- a/CordovaLib/Classes/CDVCapture.m
+++ b/CordovaLib/Classes/CDVCapture.m
@@ -383,12 +383,20 @@
             AVURLAsset* movieAsset = [[AVURLAsset alloc] initWithURL:movieURL options:nil];
             CMTime duration = [movieAsset duration];
             [formatData setObject:[NSNumber numberWithFloat:CMTimeGetSeconds(duration)] 
forKey:kW3CMediaFormatDuration];
-            CGSize size = [movieAsset naturalSize];
-            [formatData setObject:[NSNumber numberWithFloat:size.height] forKey:kW3CMediaFormatHeight];
-            [formatData setObject:[NSNumber numberWithFloat:size.width] forKey:kW3CMediaFormatWidth];
-            // not sure how to get codecs or bitrate???
-            // AVMetadataItem
-            // AudioFile
+
+            NSArray* allVideoTracks = [movieAsset tracksWithMediaType:AVMediaTypeVideo];
+            if ([allVideoTracks count] > 0) {
+                AVAssetTrack* track = [[movieAsset tracksWithMediaType:AVMediaTypeVideo]
objectAtIndex:0];
+                CGSize size = [track naturalSize];
+
+                [formatData setObject:[NSNumber numberWithFloat:size.height] forKey:kW3CMediaFormatHeight];
+                [formatData setObject:[NSNumber numberWithFloat:size.width] forKey:kW3CMediaFormatWidth];
+                // not sure how to get codecs or bitrate???
+                // AVMetadataItem
+                // AudioFile
+            } else {
+                NSLog(@"No video tracks found for %@", fullPath);
+            }
         } else if ([mimeType rangeOfString:@"audio/"].location != NSNotFound) {
             if (NSClassFromString(@"AVAudioPlayer") != nil) {
                 NSURL* fileURL = [NSURL fileURLWithPath:fullPath];
@@ -521,11 +529,12 @@
 @implementation CDVAudioNavigationController
 
 #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 60000
-- (NSUInteger)supportedInterfaceOrientations
-{
-    // delegate to CVDAudioRecorderViewController
-    return [self.topViewController supportedInterfaceOrientations];
-}
+    - (NSUInteger)supportedInterfaceOrientations
+    {
+        // delegate to CVDAudioRecorderViewController
+        return [self.topViewController supportedInterfaceOrientations];
+    }
+
 #endif
 
 @end
@@ -685,14 +694,15 @@
 }
 
 #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 60000
-- (NSUInteger)supportedInterfaceOrientations
-{
-    NSUInteger orientation = UIInterfaceOrientationMaskPortrait; // must support portrait
-    NSUInteger supported = [captureCommand.viewController supportedInterfaceOrientations];
+    - (NSUInteger)supportedInterfaceOrientations
+    {
+        NSUInteger orientation = UIInterfaceOrientationMaskPortrait; // must support portrait
+        NSUInteger supported = [captureCommand.viewController supportedInterfaceOrientations];
+
+        orientation = orientation | (supported & UIInterfaceOrientationMaskPortraitUpsideDown);
+        return orientation;
+    }
 
-    orientation = orientation | (supported & UIInterfaceOrientationMaskPortraitUpsideDown);
-    return orientation;
-}
 #endif
 
 - (void)viewDidUnload


Mime
View raw message