Using UISlider or UIProgressView to Display and Control the Playback Progress of AVAudioPlayer
While implementing audio playback with AVAudioPlayer
, you may need to display the playback progress with UIProgressView
, or even to synchronize the state of the player with UISlider
. AVAudioPlayer
doesn’t have any functionality to get periodically notified about the current playback position. However, it has 2 aptly named properties that represent the time of the current playback position and the duration of the audio file: currentTime
and duration
respectively.