Open Beyond-Chao opened 6 years ago
后续我会统一跟踪下类似的问题
期待
还有个优化点:请求权限的方法 open func requestRecordPermission(_ response: @escaping AVFoundation.PermissionBlock)
这个block可能在异步线程调用, Note that the block may be called in a different thread context. 所以UI操作最好用dispatch_async_safely_to_main_queue() 包一下。
录音过短时没有stop recorder, 录音一直在录制,当超过60s时会回调stopRecord
if self.audioTimeInterval.int32Value > 60 { self.stopRecord() }
导致还会录音成功。虽然在stopRecord里面调用了
self.operationQueue.cancelAllOperations()
如果录音时长小于0.5s时,但是子线程的while循环一直在跑,因为recorder.isRecording 是true cancelAllOperations() 的文档是这样描述: For operations that are already executing, the operation object itself must check for cancellation and stop what it is doing so that it can move to the finished state.