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
Post a Comment