Created
June 4, 2015 17:51
-
-
Save kishaningithub/0609fe899985be383a48 to your computer and use it in GitHub Desktop.
IOS Feed Live Capture
This file contains 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
class ViewController: UIViewController { | |
var session:AVCaptureSession! | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
// Do any additional setup after loading the view, typically from a nib. | |
} | |
override func viewWillAppear(animated: Bool) { | |
session = AVCaptureSession() | |
session.sessionPreset = AVCaptureSessionPresetPhoto | |
var inputDevice = AVCaptureDevice.defaultDeviceWithMediaType(AVMediaTypeVideo) | |
var deviceInput = AVCaptureDeviceInput.deviceInputWithDevice(inputDevice, error: nil) as! AVCaptureDeviceInput | |
session.addInput(deviceInput) | |
var previewLayer:AVCaptureVideoPreviewLayer = AVCaptureVideoPreviewLayer(session: session) | |
previewLayer.videoGravity = AVLayerVideoGravityResizeAspectFill | |
previewLayer.frame = self.view.frame | |
self.view.layer.insertSublayer(previewLayer, atIndex: 0) | |
session.startRunning() | |
} | |
override func didReceiveMemoryWarning() { | |
super.didReceiveMemoryWarning() | |
// Dispose of any resources that can be recreated. | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment