无故事王国
2024-06-12 21656936d06a8ea01d8d9ce4fdb1dbe0bb2e8419
DolphinEnglishLearnStudent/Config/VoicePlayer.swift
@@ -11,6 +11,7 @@
protocol VoicePlayerDelegate{
            func playComplete()
            func playing()
}
/// 音频播放器
@@ -60,6 +61,7 @@
                                    player = try? AVAudioPlayer(contentsOf: fileURL!)
                                    player?.delegate = self
                                    player?.play()
                                    delegate?.playing()
                        }else{
                                    //文件不存在:执行下载
                                    let downloadTask = URLSession.shared.downloadTask(with: URL(string: u)!) { tempLocalUrl, response, error in
@@ -70,6 +72,7 @@
                                                                        self.player = try? AVAudioPlayer(contentsOf: finalCacheUrl)
                                                                        self.player?.delegate = self
                                                                        self.player?.play()
                                                                        self.delegate?.playing()
                                                            } catch {
                                                                        print("视频缓存失败:catch")
                                                            }