سؤال

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.

هل كانت مفيدة؟

المحلول

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

نصائح أخرى

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!

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top