0

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.

Sam Baumgarten
  • 2,231
  • 3
  • 21
  • 46

2 Answers2

2

For a UISlider, I always use:

[theSlider setValue:value animated:YES];

and, it works fine for me. Why do you want a Slider to update the time though? A UIProgressView could probably do want you want. Hope that helps!

msgambel
  • 7,320
  • 4
  • 46
  • 62
1

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

EricS
  • 9,650
  • 2
  • 38
  • 34