KVO 属性列表?
List of KVO properties?
在哪里可以找到 AVPlayer 的可观察属性列表?
我似乎无法在 Apple 文档中的任何地方找到它。
AVPlayer Programing Guide 显示 KVO status
键,以及 AVPlayerItem
的可观察通知:AVPlayerItemDidPlayToEndTimeNotification
,等等
可在通知下的 AVPlayerItem docs 中找到 AVPlayerItem
可观察通知的完整列表。
AVPlayerItemDidPlayToEndTimeNotification
AVPlayerItemFailedToPlayToEndTimeNotification
AVPlayerItemTimeJumpedNotification
AVPlayerItemPlaybackStalledNotification
AVPlayerItemNewAccessLogEntryNotification
AVPlayerItemNewErrorLogEntryNotification
此外,AVPlayer.h
中对属性的注释具体说明了哪些属性是键值可观察的:status
和 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
只有当文档告诉您这是安全/适当的行为时,您才能使用 KVO。基本上,要获得您的列表,您只需搜索 "observable" 或 "observe" 或 "observing".
这个词
因此,对于 AVPlayer,参考 the docs,在 status
属性 文档下,我们阅读:
This property is key value observable using key-value observing
同样,在 outputObscuredDueToInsufficientExternalProtection
属性 文档下,我们读到:
You can observe changes to the value of this property using key-value observing
因此,答案是:AVPlayer的status
属性和它的outputObscuredDueToInsufficientExternalProtection
属性是key-value observable
但是请注意,还有其他方法可以通知 AVPlayer 发生了什么,例如通过调用 addPeriodicTimeObserverForInterval:queue:usingBlock:
或 addBoundaryTimeObserverForTimes:queue:usingBlock:
.
在哪里可以找到 AVPlayer 的可观察属性列表? 我似乎无法在 Apple 文档中的任何地方找到它。
AVPlayer Programing Guide 显示 KVO status
键,以及 AVPlayerItem
的可观察通知:AVPlayerItemDidPlayToEndTimeNotification
,等等
可在通知下的 AVPlayerItem docs 中找到 AVPlayerItem
可观察通知的完整列表。
AVPlayerItemDidPlayToEndTimeNotification
AVPlayerItemFailedToPlayToEndTimeNotification
AVPlayerItemTimeJumpedNotification
AVPlayerItemPlaybackStalledNotification
AVPlayerItemNewAccessLogEntryNotification
AVPlayerItemNewErrorLogEntryNotification
此外,AVPlayer.h
中对属性的注释具体说明了哪些属性是键值可观察的:status
和 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
只有当文档告诉您这是安全/适当的行为时,您才能使用 KVO。基本上,要获得您的列表,您只需搜索 "observable" 或 "observe" 或 "observing".
这个词因此,对于 AVPlayer,参考 the docs,在 status
属性 文档下,我们阅读:
This property is key value observable using key-value observing
同样,在 outputObscuredDueToInsufficientExternalProtection
属性 文档下,我们读到:
You can observe changes to the value of this property using key-value observing
因此,答案是:AVPlayer的status
属性和它的outputObscuredDueToInsufficientExternalProtection
属性是key-value observable
但是请注意,还有其他方法可以通知 AVPlayer 发生了什么,例如通过调用 addPeriodicTimeObserverForInterval:queue:usingBlock:
或 addBoundaryTimeObserverForTimes:queue:usingBlock:
.