Creates a metadata item intended for optional display purposes.


init(propertiesOf metadataItem: AVMetadataItem, valueLoadingHandler handler: @escaping (AVMetadataItemValueRequest) -> Void)



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.


A block that loads the value of the metadata item.

Return Value

A newly created instance of AVMetadataItem.


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).

let templateItem = // AVMetadataItem providing the values for the metadata item.
let lazyArtworkItem = AVMetadataItem(propertiesOf: templateItem) { request in
    if let image = UIImage(named: "large_artwork"),
        let imgData = UIImagePNGRepresentation(image) {
        request.respond(withValue: NSData(data:imgData))
    let error: Error = // Error to report.