2
我有一個功能,我想用它來保存視頻到相機膠捲。出於某種原因,在我停止錄製後,什麼都沒有發生?它不會將它保存到相機膠捲或者讓其他任何錯誤比將視頻保存到相機膠捲時出錯? [斯威夫特]
Error Domain=NSCocoaErrorDomain Code=-1 "(null)"
這裏是我的代碼:
@IBAction func record(_ sender: UIButton) {
if recordingInProgress{
output.stopRecording()
recordingLabel.textColor = UIColor.rgb(red: 173, green: 173, blue: 173)
PHPhotoLibrary.shared().performChanges({
PHAssetChangeRequest.creationRequestForAssetFromVideo(atFileURL: self.outputURL as URL)
}) { saved, error in
if saved {
let alertController = UIAlertController(title: "Your video was successfully saved", message: nil, preferredStyle: .alert)
let defaultAction = UIAlertAction(title: "OK", style: .default, handler: nil)
alertController.addAction(defaultAction)
self.present(alertController, animated: true, completion: nil)
}
}
}
else{
let documentsPath = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0] as NSString
let outputPath = "\(documentsPath)/output.mov"
outputURL = NSURL(fileURLWithPath: outputPath)
output.startRecording(toOutputFileURL: outputURL as URL!, recordingDelegate: self)
recordingLabel.textColor = UIColor.rgb(red: 250, green: 3, blue: 33)
}
recordingInProgress = !recordingInProgress
}