【发布时间】:2016-02-28 12:22:20
【问题描述】:
在我使用AVFoundation 的应用程序中,我在viewDidLoad 中使用NSTimer.scheduledTimerWithTimeInterval(0.1, target: self, selector: "showCurrentAudioProgress", userInfo: nil, repeats: true) 调用函数showCurrentAudioProgress()。我想返回这种时间格式 00:00:00 但我有一个大问题。整个函数如下所示:
var musicPlayer = AVAudioPLayer()
func showCurrentAudioProgress() {
self.totalTimeOfAudio = self.musicPlayer.duration
self.currentTimeOfAudio = self.musicPlayer.currentTime
let progressToShow = Float(self.currentTimeOfAudio) / Float(self.totalTimeOfAudio)
self.audioProgress.progress = progressToShow
var totalTime = self.musicPlayer.duration
totalTime -= self.currentTimeOfAudio
self.currentTimeTimer.text = "\(currentTimeOfAudio)"
self.AudioDurationTime.text = "\(totalTime)"
}
如何将使用 AVAudioPlayer 接收的时间转换为 00:00:00?
【问题讨论】:
标签: ios iphone swift time avfoundation