I am having a hard time trying to replace UISlider
on my app playing a invisible MPMoviePlayerController
with UIProgressView
.
UISlider
is just create, very intuitive to change, Pretty much on the Update selector from MPMoviePlayerController
I update its current status:
and previously I defined the min and max from the content of the MPMoviePlayerController
:
-(void)UpdateTime:(NSTimer*)Timer
{
[self.sldProgress1 setValue:[[NSNumber numberWithDouble:playerSong.currentPlaybackTime] floatValue]];
}
UIProgressView
doesn't provide similar approach, and I didn't find on the web a sample that matches what I am trying to do:
sldProgress2.maximumValue = [playerSong playableDuration];
sldProgress1.value = 0.0;
any suggestions?
UIProgressView doesn't have the concept of a user-settable max value - it's just 100.0. To make it work as you want, you'll have to do some math. Luckily, it's easy math:
CGFloat percentComplete = [playerSong.currentPlaybackTime floatValue] / [playerSong.playableDuration floatValue];
That will give you the percentage of the song that's complete, and you just update your UIProgressView to that number.
progressView.progress = percentComplete;
More or less - this code was mostly pseudo based on your question, but that's the idea.