Question

My iPhone app plays streamed audio from the Internet and I have an UISlider to scrub back and forth the already downloaded file.

This UISlider has transparent tracks, and is on top of an UIProgressView.

The UIProgressView shows the user the streamed audio download progress.

Everything works fine, but I can't figure out how to limit the scrubbing capability not beyond the already downloaded audio file, represented by this UIProgressView.

Any suggestions are welcome.

Was it helpful?

Solution

You can check if the value changed is greater than the progress then set it to the progress. Say you're handling UISlider's UIControlEventValueChanged event in this method,

- (void)valueChanged:(UISlider *)sender {
    if ( self.slider.value > self.progressView.progress ) {
        [self.slider setValue:self.progressView.progress animated:YES];
    }
}

or change the frame based on the progress.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top