Reputation: 135
Where can I find a list of observable properties for the AVPlayer? I can't seem to find it anywhere in Apple docs.
Upvotes: 2
Views: 1677
Reputation: 535566
You can use KVO only if you are told by the docs that this is safe / proper behavior. Basically, to obtain your list, you just have to search on the word "observable" or "observe" or "observing".
So, for AVPlayer, consulting the docs, under the status
property documentation, we read:
This property is key value observable using key-value observing
Similarly, under the outputObscuredDueToInsufficientExternalProtection
property documentation, we read:
You can observe changes to the value of this property using key-value observing
Thus, the answer is: The status
property of AVPlayer, and its outputObscuredDueToInsufficientExternalProtection
property, and no others, are key-value observable.
Note, however, that there are other ways of being notified of what's up with an AVPlayer, e.g. by calling addPeriodicTimeObserverForInterval:queue:usingBlock:
or addBoundaryTimeObserverForTimes:queue:usingBlock:
.
Upvotes: 2
Reputation: 42459
The AVPlayer Programing Guide shows the KVO status
key, as well as the observable notifications for AVPlayerItem
: AVPlayerItemDidPlayToEndTimeNotification
, etc.
A full list of AVPlayerItem
observable notifications can be found in the AVPlayerItem docs under Notifications.
AVPlayerItemDidPlayToEndTimeNotification
AVPlayerItemFailedToPlayToEndTimeNotification
AVPlayerItemTimeJumpedNotification
AVPlayerItemPlaybackStalledNotification
AVPlayerItemNewAccessLogEntryNotification
AVPlayerItemNewErrorLogEntryNotification
Additionally, the comments on properties in AVPlayer.h
specifically state which properties are key-value observable: status
and outputObscuredDueToInsufficientExternalProtection
:
/*!
@property status
@abstract
The ability of the receiver to be used for playback.
@discussion
The value of this property is an AVPlayerStatus that indicates whether the receiver can be used for playback. When
the value of this property is AVPlayerStatusFailed, the receiver can no longer be used for playback and a new
instance needs to be created in its place. When this happens, clients can check the value of the error property to
determine the nature of the failure. This property is key value observable.
*/
@property (nonatomic, readonly) AVPlayerStatus status;
// ...
@interface AVPlayer (AVPlayerProtectedContent)
/*!
@property outputObscuredDueToInsufficientExternalProtection
@abstract
Whether or not decoded output is being obscured due to insufficient external protection.
@discussion
The value of this property indicates whether the player is purposefully obscuring the visual output
of the current item because the requirement for an external protection mechanism is not met by the
current device configuration. It is highly recommended that clients whose content requires external
protection observe this property and set the playback rate to zero and display an appropriate user
interface when the value changes to YES. This property is key value observable.
Note that the value of this property is dependent on the external protection requirements of the
current item. These requirements are inherent to the content itself and cannot be externally specified.
If the current item does not require external protection, the value of this property will be NO.
*/
@property (nonatomic, readonly) BOOL outputObscuredDueToInsufficientExternalProtection NS_AVAILABLE_IOS(6_0);
@end
Upvotes: 1