I am using Player library, that is using AVPlayer & AVFoundation, which is quiet convenient for my case. I successfully managed to play the video and add a slider. I set the
It is preferable from an UX point of view to call the seek() method on your Player after a touchUp on your slider, rather than whenever the value changes.
As you noticed, you had poor experience with the sliderValueDidChange.
Instead, try by adding a target/action on UIControlEvents.TouchUpInside (for instance) on your slider, then only seek. The experience should be better.
var slider : UISlider! {
didSet {
slider.addTarget(self, action: Selector("touchUp:"), forControlEvents: [UIControlEvents.TouchUpInside])
}
}
func touchUp(sender:AnyObject?) {
// player.seek(slider.currentValue)
}
I solved my problem. I created an instance of Player so I was able to send the data from the view controller back to Player class. Then I simply applied seekToTime(). At this point, visually, it was seeming poor but then I noticed that I can use stop(), setCurrentTime() and then play() in order to make it look nicer.