
[英]why is audioRecorderDidFinishRecording not getting called? Able to record and play audio successfully
[英]Why does the audioRecorderDidFinishRecording function not work?
我正在开发一个iOS应用。 (iOS 11.2)当我按STOP时,我正在开发音频并转移到另一个视图。 但是以下功能不起作用。 (audioRecorderDidFinishRecording)
我尝试使用Google搜索,但是我在英语简短技能方面徘徊了很多。 请给很多建议。
class RecordSoundsViewController: UIViewController, AVAudioRecorderDelegate {
var audioRecorder: AVAudioRecorder!
@IBAction func stopRecording(_ sender: Any) {
stopRecordingButton.isEnabled = false
recordButton.isEnabled = true
recordingLabel.text = "Tap to Record"
audioRecorder.stop()
// audioRecorder = nil
let audioSession = AVAudioSession.sharedInstance()
try! audioSession.setActive(false)
// performSegue(withIdentifier: "stopRecording", sender: audioRecorder.url)
}
func audioRecorderDidFinishRecording(_ recorder: AVAudioRecorder, successfully flag: Bool) {
if flag {
performSegue(withIdentifier: "stopRecording", sender: audioRecorder.url)
} else {
print("recording was not successful")
}
}
查看您的代码,很可能您尚未为AVAudioRecorder
分配委托。
无论您在初始化AVAudioRecorder
实例的AVAudioRecorder
,在其下方尝试:
audioRecorder.delegate = self
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.