私はカスタムカメラでビデオを録画していますが、もう1つ多くです。私は再びビデオを録画したいときは何も起こりません。どのように私はこれを修正します。私はviewWillAppear()
にcameraConfigration()
メソッドをロードしています。また、録音開始録音のためにrecordVideo()
メソッドを呼び出し、停止コールStoprecording()
メソッドのためにロードしています。ここに私のコードです。スウィフト3:AVFoundationを介してビデオを再レコード
func stopRecording() {
sessionOutput.stopRecording()
captureSession.stopRunning()
previewLayer.removeFromSuperlayer()
}
func recordVideo(){
// custom camera
let paths = NSTemporaryDirectory()
let outputFile = paths.appending("t\(Timestamp).MOV")
let outputURL = NSURL(fileURLWithPath:outputFile)
sessionOutput.startRecording(toOutputFileURL: outputURL as URL!, recordingDelegate: self)
}
func cameraConfigration(){
let deviceDiscoverySession = AVCaptureDeviceDiscoverySession(deviceTypes: [AVCaptureDeviceType.builtInDuoCamera, AVCaptureDeviceType.builtInTelephotoCamera,AVCaptureDeviceType.builtInWideAngleCamera], mediaType: AVMediaTypeVideo, position: AVCaptureDevicePosition.unspecified)
for device in (deviceDiscoverySession?.devices)! {
if(device.position == AVCaptureDevicePosition.back){
do{
let input = try AVCaptureDeviceInput(device: device)
if(captureSession.canAddInput(input)){
captureSession.addInput(input);
if(captureSession.canAddOutput(sessionOutput)){
captureSession.addOutput(sessionOutput);
previewLayer = AVCaptureVideoPreviewLayer(session: captureSession);
previewLayer.videoGravity = AVLayerVideoGravityResizeAspectFill;
previewLayer.connection.videoOrientation = AVCaptureVideoOrientation.portrait;
cameraPreview.layer.addSublayer(previewLayer);
}
captureSession.startRunning()
}
}
catch{
print("exception!");
}
}
}
}
func startCameraFromViewController(viewController: UIViewController, withDelegate delegate: UIImagePickerControllerDelegate & UINavigationControllerDelegate) -> Bool {
if UIImagePickerController.isSourceTypeAvailable(.camera) == false {
return false
}
let cameraController = UIImagePickerController()
cameraController.sourceType = .camera
cameraController.mediaTypes = [kUTTypeMovie as NSString as String]
cameraController.allowsEditing = false
cameraController.delegate = delegate
present(cameraController, animated: true, completion: nil)
return true
}
override func viewDidAppear(_ animated: Bool) {
cameraConfigration()
}
``
あなたの質問に答えられたら、答えを受け入れることができますか? –