Class

AVMetadataItem

An AVMetadataItem object represents an item of metadata associated with an audiovisual asset or with one of its tracks. To create metadata items for your own assets, you use the mutable subclass, AVMutableMetadataItem.

Overview

Metadata items have keys that accord with the specification of the container format from which they’re drawn. Full details of the metadata formats, metadata keys, and metadata key spaces supported by AV Foundation are available among the defines in AV Foundation Metadata Key Constants and AV Foundation iTunes Metadata Constants.

You can load values of a metadata item “lazily” using the methods from the AVAsynchronousKeyValueLoading protocol (see Asynchronous Loading). The AVAsset class and other classes in turn provide their metadata lazily so that you can obtain objects from those arrays without incurring overhead for items you don’t ultimately inspect.

You can filter arrays of metadata items using the methods of this class. For example, you can filter by key and key space, by locale, and by preferred language.

Topics

Keys and Key Spaces

var key: (NSCopying & NSObjectProtocol)?

The key of the metadata item.

var keySpace: AVMetadataKeySpace?

The key space of metadata item’s key.

var commonKey: AVMetadataKey?

The common key of the metadata item.

Accessing Values

var value: (NSCopying & NSObjectProtocol)?

The value of the metadata item.

var time: CMTime

The timestamp of the metadata item.

var duration: CMTime

The duration of the metadata item.

var locale: Locale?

The locale of the metadata item.

var dataValue: Data?

Provides the raw bytes of the value of the metadata item.

var extraAttributes: [AVMetadataExtraAttributeKey : Any]?

The additional attributes supplied by the metadata item.

var dataType: String?

Indicates the data type of the metadata item's value.

var extendedLanguageTag: String?

The IETF BCP 47 (RFC 4646) language identifier of the metadata item.

var identifier: AVMetadataIdentifier?

Indicates the identifier of the metadata item.

var startDate: Date?

Indicates the start date of the timed metadata; nil if no date is indicated.

class func identifier(forKey: Any, keySpace: AVMetadataKeySpace)

Provides the metadata identifier that’s equivalent to a key and key space.

class func key(forIdentifier: AVMetadataIdentifier)

Provides the metadata key indicated by the identifier.

class func keySpace(forIdentifier: AVMetadataIdentifier)

Gets the metadata keySpace indicated by the identifier.

Type Coercion

var stringValue: String?

The value of the metadata item formatted as a string.

var numberValue: NSNumber?

The value of the metadata item formatted as a number.

var dateValue: Date?

The value of the metadata item formatted as a date.

Filtering Arrays of Metadata Items

class func metadataItems(from: [AVMetadataItem], withKey: Any?, keySpace: AVMetadataKeySpace?)

Provides an array of metadata items that match a specified key or key space.

class func metadataItems(from: [AVMetadataItem], with: Locale)

Provides an array of metadata items that match a specified locale.

class func metadataItems(from: [AVMetadataItem], filteredAndSortedAccordingToPreferredLanguages: [String])

Provides the subset of metadata items whose locales match one of the specified language identifiers.

class func metadataItems(from: [AVMetadataItem], filteredBy: AVMetadataItemFilter)

Filters an array of metadata items using the metadata item filter.

init(propertiesOf: AVMetadataItem, valueLoadingHandler: (AVMetadataItemValueRequest) -> Void)

Creates a metadata item intended for optional display purposes.