Search code examples
iphonesdkuislideravplayercmtime

Im trying to update a UISlider with the current time from a AVPlayer


I'm trying to update a UISlider with the current time from a AVPlayer. Im using a NSTimer to call a method with this code every 1 second:

CMTime duration = audioPlayer.currentTime; float seconds = CMTimeGetSeconds(duration); NSLog(@"duration: %.2f", seconds); nowPlayingSlider.value = seconds;

The Times being logged right but the uislider never updates.


Solution

  • Make sure you set the maximumValue property of the UISlider to the duration of the media. It defaults to 1.0.