Type Method

metadataItemWithPropertiesOfMetadataItem:valueLoadingHandler:

Creates a metadata item intended for optional display purposes.

Declaration

+ (AVMetadataItem *)metadataItemWithPropertiesOfMetadataItem:(AVMetadataItem *)metadataItem valueLoadingHandler:(void (^)(AVMetadataItemValueRequest *valueRequest))handler;

Parameters

metadataItem

A metadata item with the identifier, extendedLanguageTag, and other property values that you want the newly created AVMetadataItem instance to share. The value of metadataItem is ignored.

handler

A block that loads the value of the metadata item.

Return Value

A newly created instance of AVMetadataItem.

Discussion

You use this method to create metadata items you intend for optional display purposes, such as those used for navigation markers presented by an AVPlayerViewController. When the value of this metadata item is requested, the block you provide as the value loading handler will be executed on an arbitrary dispatch queue, off the main thread. The handler can perform I/O and other necessary operations to obtain the value. If loading of the value succeeds, you provide the value by invoking the value request’s respondWithValue: method; otherwise, you provide an instance of NSError that describes the failure by calling its respondWithError: method (see example).

AVMetadataItem *templateItem = // Item providing the values for the metadata item.
AVMetadataItem *lazyArtworkItem =
    [AVMetadataItem metadataItemWithPropertiesOfMetadataItem:templateItem
        valueLoadingHandler:^(AVMetadataItemValueRequest *request) {
        UIImage *image = [UIImage imageNamed:@"large_artwork"];
        if (image) {
            [request respondWithValue:(id)image];
        } else {
            NSError *error = // NSError to report.
            [request respondWithError:error];
        }
    }];