Advertisement
Guest User

Untitled

a guest
Apr 16th, 2014
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.62 KB | None | 0 0
  1. UIImagePickerController * videoRecorder = [[UIImagePickerController alloc] init];
  2.  
  3. videoRecorder.delegate = self;
  4. videoRecorder.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
  5. videoRecorder.mediaTypes = [[NSArray alloc] initWithObjects:(NSString *)kUTTypeMovie, nil];
  6. [self presentViewController:videoRecorder animated:YES completion:nil];
  7.  
  8. @interface ALAssetsLibrary (VideoOrientation)
  9.  
  10. + (UIInterfaceOrientation)orientationForTrack:(AVAsset *)asset;
  11.  
  12. @end
  13.  
  14.  
  15. @implementation ALAssetsLibrary (VideoOrientation)
  16.  
  17.  
  18. + (UIInterfaceOrientation)orientationForTrack:(AVAsset *)asset
  19. {
  20. NSArray *videoAssets = [asset tracksWithMediaType:AVMediaTypeVideo];
  21.  
  22. if (!videoAssets.count)
  23. {
  24. NSLog(@"No video assets found.");
  25. return UIInterfaceOrientationPortrait;
  26. }
  27.  
  28. // Get the video track.
  29. AVAssetTrack *videoTrack = [videoAssets objectAtIndex:0];
  30.  
  31. CGSize size = [videoTrack naturalSize];
  32. CGAffineTransform preferredTransform = [videoTrack preferredTransform];
  33.  
  34. // Return interface orientation based on
  35. // the preferred transform and size of the video.
  36. if (size.width == preferredTransform.tx &&
  37. size.height == preferredTransform.ty)
  38. {
  39. return UIInterfaceOrientationLandscapeRight;
  40. }
  41. else if (preferredTransform.tx == 0 &&
  42. preferredTransform.ty == 0)
  43. {
  44. return UIInterfaceOrientationLandscapeLeft;
  45. }
  46. else if (preferredTransform.tx == 0 &&
  47. preferredTransform.ty == size.width)
  48. {
  49. return UIInterfaceOrientationPortraitUpsideDown;
  50. }
  51. else
  52. {
  53. return UIInterfaceOrientationPortrait;
  54. }
  55. }
  56.  
  57. @end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement