 
         HappieCameraJSON.initializeProcessingCount();
 
-        _ = AVCaptureDevice.devices(withMediaType: AVMediaTypeVideo)
+        _ = AVCaptureDevice.devices(for: AVMediaType.video)
 
         let devices = AVCaptureDevice.devices()
 
         // Loop through all the capture devices on this phone
-        for device in devices! {
+        for device in devices {
             // Make sure this particular device supports video
-            if ((device as AnyObject).hasMediaType(AVMediaTypeVideo)) {
+            if ((device as AnyObject).hasMediaType(AVMediaType.video)) {
                 // Finally check the position and confirm we've got the back camera
-                if((device as AnyObject).position == AVCaptureDevicePosition.back) {
+                if((device as AnyObject).position == AVCaptureDevice.Position.back) {
                     backCameraDevice = device as? AVCaptureDevice
                 }
             }


        previewLayer?.frame = CGRect(x: 0, y: 0, width: width,height: height)
        previewLayer?.bounds = CGRect(x: 0, y: 0,width: width,height: height)
        previewLayer?.videoGravity = AVLayerVideoGravityResizeAspectFill;
        
        previewLayer?.connection.videoOrientation = AVCaptureVideoOrientation(rawValue: orientation.rawValue)!;
        camPreview.layer.addSublayer(previewLayer!)

        captureSession.startRunning()

@objc protocol cameraDelegate{ func cameraFinished(_ controller: HappieCameraViewController) }

@objc(HappieCameraViewController) class HappieCameraViewController : UIViewController, AVCaptureFileOutputRecordingDelegate  {
    func fileOutput(_ output: AVCaptureFileOutput, didFinishRecordingTo outputFileURL: URL, from connections: [AVCaptureConnection], error: Error?) {

    }


    //MARK: Class Variables
    let captureSession = AVCaptureSession() //provides a UI context for capturing media
