Reputation: 2259
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.
Upvotes: 0
Views: 1535
Reputation: 9768
Make sure you set the maximumValue property of the UISlider to the duration of the media. It defaults to 1.0.
Upvotes: 1
Reputation: 7340
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!
Upvotes: 2