IOS development app video recording instance

Source: Internet
Author: User

IOSDevelop applicationsVideo RecordingThe instance is the content to be introduced in this article. This section uses Apple's own cameraVideoThe code is shared by CocoaChina member "1056975026", which helps developers who use the photo and video functions in the developed applications.

 
 
  1. (Void) choosePhotoBySourceType: (UIImagePickerControllerCameraCaptureMode) sourceType
  2. {
  3. M_imagePickerController = [[[UIImagePickerController alloc] init] autorelease];
  4. M_imagePickerController.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
  5. M_imagePickerController.sourceType = UIImagePickerControllerSourceTypeCamera;
  6. M_imagePickerController.cameraDevice = UIImagePickerControllerCameraDeviceFront;
  7. // M_imagePickerController.cameraCaptureMode = UIImagePickerControllerCameraCaptureModeVideo;
  8. NSArray * sourceTypes = [UIImagePickerController availableMediaTypesForSourceType: m_imagePickerController.sourceType];
  9. If ([sourceTypes containsObject :( NSString *) kUTTypeMovie])
  10. {
  11. M_imagePickerController.mediaTypes = [NSArray arrayWithObjects :( NSString *) kUTTypeMovie, (NSString *) kUTTypeImage, nil];
  12. }
  13. // M_imagePickerController.cameraCaptureMode = sourceType;
  14. // M_imagePickerController.mediaTypes
  15. // ImagePickerController. allowsEditing = YES;
  16. [Self presentModalViewController: m_imagePickerController animated: YES];
  17. }
  18. -(Void) takePhoto
  19. {
  20. If ([UIImagePickerController isSourceTypeAvailable: UIImagePickerControllerSourceTypeCamera])
  21. {
  22. [Self choosePhotoBySourceType: nil];
  23. }
  24. }
  25. // Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
  26. -(Void) viewDidLoad {
  27. [Super viewDidLoad];
  28. UIButton * takePhoto = [UIButton buttonWithType: UIButtonTypeRoundedRect];
  29. [TakePhoto setTitle: @ "video" forState: UIControlStateNormal];
  30. [TakePhoto addTarget: self action: @ selector (takePhoto) forControlEvents: UIControlEventTouchUpInside];
  31. TakePhoto. frame = CGRectMake (50,100,100, 30 );
  32. [Self. view addSubview: takePhoto];

Summary:IOSDevelop applicationsVideo RecordingI hope this article will help you with the introduction of the instance!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.