AVAsynchronousKeyValueLoading

Trait AVAsynchronousKeyValueLoading 

Source
pub unsafe trait AVAsynchronousKeyValueLoading {
    // Provided method
    unsafe fn loadValuesAsynchronouslyForKeys_completionHandler(
        &self,
        keys: &NSArray<NSString>,
        handler: Option<&DynBlock<dyn Fn()>>,
    )
       where Self: Sized + Message { ... }
}
Available on crate feature 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:

  1. First, determine whether the value for a given key is available using statusOfValueForKey:error:.
  2. 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§

Source

unsafe fn loadValuesAsynchronouslyForKeys_completionHandler( &self, keys: &NSArray<NSString>, handler: Option<&DynBlock<dyn Fn()>>, )
where Self: Sized + Message,

Available on crate feature 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.

§Safety

handler block must be sendable.

Trait Implementations§

Source§

impl ProtocolType for dyn AVAsynchronousKeyValueLoading

Source§

const NAME: &'static str = "AVAsynchronousKeyValueLoading"

The name of the Objective-C protocol that this type represents. Read more
Source§

fn protocol() -> Option<&'static AnyProtocol>

Get a reference to the Objective-C protocol object that this type represents. Read more
Source§

impl<T> ImplementedBy<T> for dyn AVAsynchronousKeyValueLoading

Implementations on Foreign Types§

Source§

impl<T> AVAsynchronousKeyValueLoading for ProtocolObject<T>

Implementors§

Source§

impl AVAsynchronousKeyValueLoading for AVAsset

Available on crate feature AVAsset only.
Source§

impl AVAsynchronousKeyValueLoading for AVAssetTrack

Available on crate feature AVAssetTrack only.
Source§

impl AVAsynchronousKeyValueLoading for AVComposition

Available on crate feature AVComposition only.
Source§

impl AVAsynchronousKeyValueLoading for AVCompositionTrack

Available on crate feature AVCompositionTrack only.
Source§

impl AVAsynchronousKeyValueLoading for AVFragmentedAsset

Available on crate feature AVAsset only.
Source§

impl AVAsynchronousKeyValueLoading for AVFragmentedAssetTrack

Available on crate feature AVAssetTrack only.
Source§

impl AVAsynchronousKeyValueLoading for AVFragmentedMovie

Available on crate feature AVMovie only.
Source§

impl AVAsynchronousKeyValueLoading for AVFragmentedMovieTrack

Available on crate feature AVMovieTrack only.
Source§

impl AVAsynchronousKeyValueLoading for AVMetadataItem

Available on crate feature AVMetadataItem only.
Source§

impl AVAsynchronousKeyValueLoading for AVMovie

Available on crate feature AVMovie only.
Source§

impl AVAsynchronousKeyValueLoading for AVMovieTrack

Available on crate feature AVMovieTrack only.
Source§

impl AVAsynchronousKeyValueLoading for AVMutableComposition

Available on crate feature AVComposition only.
Source§

impl AVAsynchronousKeyValueLoading for AVMutableCompositionTrack

Available on crate feature AVCompositionTrack only.
Source§

impl AVAsynchronousKeyValueLoading for AVMutableMetadataItem

Available on crate feature AVMetadataItem only.
Source§

impl AVAsynchronousKeyValueLoading for AVMutableMovie

Available on crate feature AVMovie only.
Source§

impl AVAsynchronousKeyValueLoading for AVMutableMovieTrack

Available on crate feature AVMovieTrack only.
Source§

impl AVAsynchronousKeyValueLoading for AVURLAsset

Available on crate feature AVAsset only.