音频播放完成后,我有一个关于更改图像的问题。我如何改变细胞的形象?请帮我。我打印了#34; Done"与' audioPlayerDidFinishPlaying'但我不知道如何控制细胞图像等。
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
if messageList[indexPath.row].fileAudioUid != nil {
let url = "..."
startDownload(audioUrl: url)
}
}
var audioPlayer : AVAudioPlayer!
func startDownload(audioUrl:String) -> Void {
let fileUrl = self.getSaveFileUrl(fileName: audioUrl)
let destination: DownloadRequest.DownloadFileDestination = { _, _ in
return (fileUrl, [.removePreviousFile, .createIntermediateDirectories])
}
Alamofire.download(audioUrl, to:destination)
.downloadProgress { (progress) in
print(progress)
}
.responseData { (data) in
let url1 = data.destinationURL?.absoluteURL
print(url1!)
do {
self.audioPlayer = try AVAudioPlayer(contentsOf: url1!)
self.audioPlayer.delegate = self
self.audioPlayer.prepareToPlay()
self.audioPlayer.play()
}catch let error {
print(error)
}
}
}
func audioPlayerDidFinishPlaying(_ player: AVAudioPlayer, successfully flag: Bool) {
if flag {
print("Done")
} else {
// did not finish successfully
}
}