andreipitis / ASPVideoPlayer

A simple video player that allow animations to be performed on the view during playback.
MIT License
89 stars 43 forks source link

progress more smooth? #4

Closed davidseek closed 7 years ago

davidseek commented 7 years ago

Hey. Is there a way to have the progress more smooth?

Tried:

let positionDouble = Double(self.videoPlayer.currentTime)
let durationDouble = Double(self.videoPlayer.videoLength)
let float = Float(positionDouble / durationDouble)

as well as the progress by self.videoPlayer. Both values are fired in 3-4-5% steps. So my progress slider is "jumping" from value to value. Is it possible to receive 0.5-1% value steps of the current video play progress?

andreipitis commented 7 years ago

Hi,

The progress value in the playingVideo closure is equal to currentTime / videoLength. The jumping is happening because based on the video length the size for a single step will be different (the longer the video, the smaller the step). If you have a fairly long video (> 2-3 minutes), there should be no noticeable jumping.

The playingVideo closure is called every 0.5 seconds, so you could do some custom logic to get a smooth slider.

One solution would be to have something like this:

UIView.animate(withDuration: 0.8, animations: {
    self.slider.setValue(Float(progress), animated: true)
})
davidseek commented 7 years ago

awesome idea with the animation. thank you