如何在音频播放结束后再次播放相同的音频?现在我使用AVPlayer这段代码:
fileprivate func play () {
guard let url = URL(string: record.recordUrl) else { return }
let playItem = AVPlayerItem(url: url)
player.replaceCurrentItem(with: playItem)
NotificationCenter.default.addObserver(self, selector: #selector(playerDidFinishPlaying), name: NSNotification.Name.AVPlayerItemDidPlayToEndTime, object: playItem)
player.play()
}
@objc func playerDidFinishPlaying(note: NSNotification) {
print("Player finished")
currentTimeSlider.setValue(0, animated: true)
currentTimeLabel.text = "00:00"
}