修复录音无法播放问题
This commit is contained in:
@@ -68,11 +68,12 @@ class PlayVoiceManager: NSObject,AVAudioPlayerDelegate {
|
||||
let downloadTask = session.downloadTask(with: request,
|
||||
completionHandler: { (location:URL?, response:URLResponse?, error:Error?)
|
||||
-> Void in
|
||||
let locationPath = location!.path
|
||||
if FileManager.default.fileExists(atPath: path){
|
||||
try? FileManager.default.removeItem(atPath: path)
|
||||
}
|
||||
guard let locationPath = location?.path else{return}
|
||||
|
||||
do {
|
||||
if FileManager.default.fileExists(atPath: path){
|
||||
try FileManager.default.removeItem(atPath: path)
|
||||
}
|
||||
// 文件移动至document
|
||||
try FileManager.default.copyItem(atPath: locationPath, toPath: path)
|
||||
// main
|
||||
@@ -80,15 +81,8 @@ class PlayVoiceManager: NSObject,AVAudioPlayerDelegate {
|
||||
self.beginPlayVoice(url:path)
|
||||
}
|
||||
} catch let error {
|
||||
debugPrint(error)
|
||||
HUDTool.show(with: "\(error.localizedDescription)")
|
||||
}
|
||||
// let data = NSData.init(contentsOfFile: locationPath)
|
||||
// if let _data = data {
|
||||
// let isHave = _data.write(toFile: path, atomically: true)
|
||||
// print(isHave)
|
||||
// self.beginPlayVoice(url:path)
|
||||
// }
|
||||
})
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user