Requests the periodic invocation of a given block during playback to report changing time.
- iOS 4.0+
- macOS 10.7+
- Mac Catalyst 13.0+
- tvOS 9.0+
- watchOS 6.0+
The time interval at which the
blockshould be invoked during normal playback, according to progress of the player’s current time.
A serial dispatch queue onto which
blockshould be enqueued. Passing a concurrent queue is not supported and will result in undefined behavior.
If you pass
NULL, the main queue is used.
The block to be invoked periodically.
The block takes a single parameter:
The time at which the block is invoked.
An opaque object that you pass as the argument to
remove to cancel observation.
You must maintain a strong reference the returned value as long as you want the time observer to be invoked by the player. Each invocation of this method should be paired with a corresponding call to
remove. Releasing the observer object without invoking
remove will result in undefined behavior.
The block is invoked periodically at the interval specified, interpreted according to the timeline of the current item. The block is also invoked whenever time jumps and whenever playback starts or stops. If the interval corresponds to a very short interval in real time, the player may invoke the block less frequently than requested. Even so, the player will invoke the block sufficiently often for the client to update indications of the current time appropriately in its end-user interface.
The following example illustrates how you would set up a callback to be fired every half second during normal playback.