pub unsafe trait AVAsynchronousKeyValueLoading {
// Provided method
unsafe fn loadValuesAsynchronouslyForKeys_completionHandler(
&self,
keys: &NSArray<NSString>,
handler: Option<&Block<dyn Fn()>>,
)
where Self: Sized + Message { ... }
}AVAsynchronousKeyValueLoading only.Expand description
The AVAsynchronousKeyValueLoading protocol defines methods that let clients use an AVAsset or AVAssetTrack object without blocking a thread. Using methods in the protocol, one can find out the current status of a key (for example, whether the corresponding value has been loaded); and ask the object to load values asynchronously, informing the client when the operation has completed.
Because of the nature of timed audiovisual media, successful initialization of an asset does not necessarily mean that all its data is immediately available. Instead, an asset will wait to load data until an operation is performed on it (for example, directly invoking any relevant AVAsset methods, playback via an AVPlayerItem object, export using AVAssetExportSession, reading using an instance of AVAssetReader, and so on). This means that although you can request the value of any key at any time, and its value will be returned synchronously, the calling thread may be blocked until the request can be satisfied. To avoid blocking, you can:
- First, determine whether the value for a given key is available using statusOfValueForKey:error:.
- If a value has not been loaded yet, you can ask for to load one or more values and be notified when they become available using loadValuesAsynchronouslyForKeys:completionHandler:.
Even for use cases that may typically support ready access to some keys (such as for assets initialized with URLs for files in the local filesystem), slow I/O may require AVAsset to block before returning their values. Although blocking may be acceptable for macOS API clients in cases where assets are being prepared on background threads or in operation queues, in all cases in which blocking should be avoided you should use loadValuesAsynchronouslyForKeys:completionHandler:. For clients of platforms other than macOS, blocking to obtain the value of a key synchronously is never recommended under any circumstances.
See also Apple’s documentation
Provided Methods§
Sourceunsafe fn loadValuesAsynchronouslyForKeys_completionHandler(
&self,
keys: &NSArray<NSString>,
handler: Option<&Block<dyn Fn()>>,
)
Available on crate feature block2 only.
unsafe fn loadValuesAsynchronouslyForKeys_completionHandler( &self, keys: &NSArray<NSString>, handler: Option<&Block<dyn Fn()>>, )
block2 only.Directs the target to load the values of any of the specified keys that are not already loaded.
Parameter keys: An instance of NSArray, containing NSStrings for the specified keys.
Parameter handler: The block to be invoked when loading succeeds, fails, or is cancelled.
Trait Implementations§
Source§impl ProtocolType for dyn AVAsynchronousKeyValueLoading
impl ProtocolType for dyn AVAsynchronousKeyValueLoading
impl<T> ImplementedBy<T> for dyn AVAsynchronousKeyValueLoading
Implementations on Foreign Types§
impl<T> AVAsynchronousKeyValueLoading for ProtocolObject<T>where
T: ?Sized + AVAsynchronousKeyValueLoading,
Implementors§
impl AVAsynchronousKeyValueLoading for AVAsset
AVAsset only.impl AVAsynchronousKeyValueLoading for AVAssetTrack
AVAssetTrack only.impl AVAsynchronousKeyValueLoading for AVComposition
AVAsset and AVComposition only.impl AVAsynchronousKeyValueLoading for AVCompositionTrack
AVAssetTrack and AVCompositionTrack only.impl AVAsynchronousKeyValueLoading for AVFragmentedAsset
AVAsset only.impl AVAsynchronousKeyValueLoading for AVFragmentedAssetTrack
AVAssetTrack only.impl AVAsynchronousKeyValueLoading for AVFragmentedMovie
AVAsset and AVMovie only.impl AVAsynchronousKeyValueLoading for AVFragmentedMovieTrack
AVAssetTrack and AVMovieTrack only.impl AVAsynchronousKeyValueLoading for AVMetadataItem
AVMetadataItem only.impl AVAsynchronousKeyValueLoading for AVMovie
AVAsset and AVMovie only.impl AVAsynchronousKeyValueLoading for AVMovieTrack
AVAssetTrack and AVMovieTrack only.impl AVAsynchronousKeyValueLoading for AVMutableComposition
AVAsset and AVComposition only.impl AVAsynchronousKeyValueLoading for AVMutableCompositionTrack
AVAssetTrack and AVCompositionTrack only.impl AVAsynchronousKeyValueLoading for AVMutableMetadataItem
AVMetadataItem only.impl AVAsynchronousKeyValueLoading for AVMutableMovie
AVAsset and AVMovie only.impl AVAsynchronousKeyValueLoading for AVMutableMovieTrack
AVAssetTrack and AVMovieTrack only.impl AVAsynchronousKeyValueLoading for AVURLAsset
AVAsset only.