AVPlayer smooth seekToTime

373 views Asked by At

Is where a way to smoothly seek playback to some position?

In other words, imagine that some track playing at 0:53 and I need it to play at 0:58 after 2 seconds. So I need it to smoothly increase rate (like using easing functions in animation) and smoothly decrease rate when playback time almost equal 0:58. (it should sound like rewind effect)

Simple seekToTime method is not an option since it just jumps to position.

Here is an illustration:

two________________________seconds_________________________to_seek

0:53__________________________________________________________0:58

|____________↑_________|__________=_________|__________↓__________|

rate=1______smoothly_rate=2.0_______________smoothly_rate=1_____rate=1


I've already tried to use easing methods to smoothly increase rate but looks like it's impossible - rate value changes right away to desired value without easing.

At least I know that it is actually possible. You can try Ampme app from Appstore. They're playing music synchronously on different devices and if there is some lag (buffering, etc) on one of the devices, it's playback smoothly corrects to right value without jumping.

Currently I'm using setRate:time:atHostTime: method and I think it's the right way, but I'm not able to make it work seeking smoothly.

0

There are 0 answers