- (void)viewDidLoad {
[super viewDidLoad];
self.slider.maximumValue = 30;
}
- (void)slide:(UISlider *)slider {
NSLog(@"....progress slider value:%d", (int)slider.value);
CMTime showingTime = CMTimeMakeWithSeconds((int)slider.value, 1);
[self.player seekToTime:showingTime];
}
Everytime I slide the UISlider, The console log the right number as I slided. like 6 seconds. But the slider would jump back to 0; If I slide it to value bigger than 10, like 14, It would slide back to 10.
Can anybody help me ? Thanks
Try this.
You gotta init a CMTime object based on UISlider's value at first. Then you call AVPlayer object's seek to time method. Pass the CMTime object as parameter.
CMTime showingTime = CMTimeMake(slider.value *1000, 1000);
[self.player seekToTime:showingTime toleranceBefore:kCMTimeZero toleranceAfter:kCMTimeZero];