Last active
July 29, 2016 11:23
-
-
Save akesson/4a9809e4514375bebb418465959c7ca8 to your computer and use it in GitHub Desktop.
[iOS] Picking a video
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//https://www.raywenderlich.com/94404/play-record-merge-videos-ios-swift | |
// MARK: - UIImagePickerControllerDelegate | |
extension PlayVideoViewController: UIImagePickerControllerDelegate { | |
func imagePickerController(picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [NSObject : AnyObject]) { | |
let mediaType = info[UIImagePickerControllerMediaType] as! NSString | |
dismissViewControllerAnimated(true) { | |
if mediaType == kUTTypeMovie { | |
let videoURL = info[UIImagePickerControllerMediaURL] as! NSURL | |
//TODO call method that decompresses the video and send it to the metal | |
} | |
} | |
} | |
} | |
// MARK: - UINavigationControllerDelegate | |
extension PlayVideoViewController: UINavigationControllerDelegate { | |
} | |
func startMediaBrowserFromViewController(viewController: UIViewController, usingDelegate delegate: protocol<UINavigationControllerDelegate, UIImagePickerControllerDelegate>) -> Bool { | |
if UIImagePickerController.isSourceTypeAvailable(.SavedPhotosAlbum) == false { | |
return false | |
} | |
var mediaUI = UIImagePickerController() | |
mediaUI.sourceType = .SavedPhotosAlbum | |
mediaUI.mediaTypes = [kUTTypeMovie as NSString as String] | |
mediaUI.allowsEditing = true | |
mediaUI.delegate = delegate | |
presentViewController(mediaUI, animated: true, completion: nil) | |
return true | |
} | |
//call to show it: | |
startMediaBrowserFromViewController(self, usingDelegate: self) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment