修复录音无法播放问题
This commit is contained in:
@@ -68,11 +68,12 @@ class PlayVoiceManager: NSObject,AVAudioPlayerDelegate {
|
|||||||
let downloadTask = session.downloadTask(with: request,
|
let downloadTask = session.downloadTask(with: request,
|
||||||
completionHandler: { (location:URL?, response:URLResponse?, error:Error?)
|
completionHandler: { (location:URL?, response:URLResponse?, error:Error?)
|
||||||
-> Void in
|
-> Void in
|
||||||
let locationPath = location!.path
|
guard let locationPath = location?.path else{return}
|
||||||
if FileManager.default.fileExists(atPath: path){
|
|
||||||
try? FileManager.default.removeItem(atPath: path)
|
|
||||||
}
|
|
||||||
do {
|
do {
|
||||||
|
if FileManager.default.fileExists(atPath: path){
|
||||||
|
try FileManager.default.removeItem(atPath: path)
|
||||||
|
}
|
||||||
// 文件移动至document
|
// 文件移动至document
|
||||||
try FileManager.default.copyItem(atPath: locationPath, toPath: path)
|
try FileManager.default.copyItem(atPath: locationPath, toPath: path)
|
||||||
// main
|
// main
|
||||||
@@ -80,15 +81,8 @@ class PlayVoiceManager: NSObject,AVAudioPlayerDelegate {
|
|||||||
self.beginPlayVoice(url:path)
|
self.beginPlayVoice(url:path)
|
||||||
}
|
}
|
||||||
} catch let error {
|
} catch let error {
|
||||||
debugPrint(error)
|
|
||||||
HUDTool.show(with: "\(error.localizedDescription)")
|
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