how to set device orientation in swift 4

var isStarted:Bool!

func returnedOrientation() ->AVCaptureVideoOrientation  

{        

      var videoOrientation: AVCaptureVideoOrientation!        

let orientation = UIDevice.current.orientation                

switch orientation {        

          case .unknown:            break        

        case .portrait: videoOrientation = .portrait        

case .portraitUpsideDown:            videoOrientation = .portraitUpsideDown        

case .landscapeLeft:            videoOrientation = .landscapeRight        

case .landscapeRight:            videoOrientation = .landscapeLeft        

case .faceUp: break        

case .faceDown:break       

 }        

return videoOrientation   

 }    

@IBAction func btnRecordVideoClicked(_ sender: Any)

 {        

if isStarted == false

 {            

isStarted = true            //self.sartTimer()

            movieOutput.connection(with: AVMediaType.video)?.videoOrientation = returnedOrientation()

            movieOutput.startRecording(to: your_local_path, recordingDelegate: self)

        } 

else {

            isStarted = false

            timerCode.invalidate()            //self.movieOutput.stopRecording()

        }

    }

Comments

Popular posts from this blog

Windows Keys

how to send invite and give a access of selected application on App Store

how to display popover in TableView cell in swift