음악 플레이어
iPhone 11 Pro Max | iPhone 8 |
---|---|
Play | Pause | Stop |
---|---|---|
Record | Stop | Play |
---|---|---|
audioFile = Bundle.main.url(forResource: "hello_world", withExtension: "mp3")
func convertNSTimeInterval2String(_ time: TimeInterval) -> String {
}
var progressTimer: Timer!
progressTimer = Timer.scheduledTimer(timeInterval: 0.1, target: self, selector: timePlayerSelector, userInfo: nil, repeats: true)
let timePlayerSelector: Selector = #selector(AudioViewController.updatePlayTime)
@objc func updatePlayTime() {
labelCurrentTime.text = convertNSTimeInterval2String(audioPlayer.currentTime)
progressViewPlay.progress = Float(audioPlayer.currentTime / audioPlayer.duration )
}
progressTimer.invalidate()
let documentDirectory = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0]
audioFile = documentDirectory.appendingPathComponent("recordFile.m4a")