             captureSession.sessionPreset = AVCaptureSessionPresetPhoto
         }
         self.recordingModePhoto = !self.recordingModePhoto
+        captureSession.startRunning()
     }
     
     @IBAction func changeCamera(sender: UIButton) {

                
                let backDevice = getDevice(.Front)
                self.captureDevice = backDevice
                beginSession()
                sender.setTitle("back", forState: .Normal)
            }catch{
                print("Cant remove input: \(error)")

    
    override func viewDidLoad() {
        super.viewDidLoad()
        configureSession()
        
    }
    func configureSession(){
        if let _ = captureSession where captureSession.running {
            captureSession.stopRunning()
        }
        captureSession = AVCaptureSession()
        captureSession.sessionPreset = AVCaptureSessionPresetPhoto
        
        self.sessionQueue = dispatch_queue_create("camera_session", DISPATCH_QUEUE_SERIAL)
        
        captureDevice = getDevice(currentPosition)
        beginSession()
        addAudioInputAndStillImageOutputInSession()
        //let recordingDelegate:AVCaptureFileOutputRecordingDelegate? = self
        
        videoFileOutput = AVCaptureMovieFileOutput()
        self.captureSession.addOutput(videoFileOutput)
    }
    
    @IBAction func takeVideoAction(sender: AnyObject) {
        captureSession.stopRunning()
        if viewX.hidden{
            viewX.hidden = false
            return
