Is there way to set up an observer / callback on an AVPlayer
to get notified when the frame changes?
I am aware of both addBoundaryTimeObserver
and addPeriodicTimeObserver
however these are approximations that require me to estimate the frame rate, etc.
There is a note that:
General State Observations: You can use Key-value observing (KVO) to observe state changes to many of the player’s dynamic properties, such as its currentItem or its playback rate. You should register and unregister for KVO change notifications on the main thread. This avoids the possibility of receiving a partial notification if a change is being made on another thread. AV Foundation invokes observeValue(forKeyPath:of:change:context:) on the main thread, even if the change operation is made on another thread.
However currentTime
on AVPlayerItem
is a method, not a property so I cannot use KVO for that.