<!--
{
  "availability" : [
    "iOS: 9.3.0 -",
    "iPadOS: 9.3.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.11.3 -",
    "tvOS: 9.2.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.3.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AVFoundation",
  "identifier" : "/documentation/AVFoundation/AVPlayerItemMetadataCollector/init(identifiers:classifyingLabels:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "AVFoundation"
    ],
    "preciseIdentifier" : "c:objc(cs)AVPlayerItemMetadataCollector(im)initWithIdentifiers:classifyingLabels:"
  },
  "title" : "init(identifiers:classifyingLabels:)"
}
-->

# init(identifiers:classifyingLabels:)

Creates a metadata collector to access a stream’s metadata groups matching the specified array of identifiers and classifying labels.

```
init(identifiers: [String]?, classifyingLabels: [String]?)
```

## Parameters

`identifiers`

An optional array of metadata identifiers indicating the metadata items that the output should provide.

`classifyingLabels`

A optional array of classifying labels indicating the metadata items that the output should provide.

## Return Value

An instance of `AVPlayerItemMetadataCollector`.

## Discussion

You can use the `identifiers` and `classifyingLabels` arguments to configure the metadata collector to filter its output to only the metadata items matching the specified criteria.

You use the `identifiers` argument to filter the output to a particular set of metadata identifiers. For instance, if the stream’s `#EXT-X-DATERANGE` tags define multiple metadata attributes, but you are only interested in the values for the `X-AD-ID` and `X-AD-URL` attributes, you could configure the collector as follows:

```swift
let adID = AVMetadataItem.identifier(forKey: "X-AD-ID",
                                     keySpace: AVMetadataKeySpaceHLSDateRange)!
let adURL = AVMetadataItem.identifier(forKey: "X-AD-URL",
                                      keySpace: AVMetadataKeySpaceHLSDateRange)!
metadataCollector = AVPlayerItemMetadataCollector(identifiers: [adID, adURL],
                                                  classifyingLabels: nil)
```

The `classifyingLabels` argument is used to filter by the `#EXT-X-DATERANGE` tag’s `CLASS` attribute. The `CLASS` attribute can be used to define a set of attribute/value pairs for a particular purpose (such as describing an ad) and then mark each `#EXT-X-DATERANGE` instance as having those semantics. For instance, this might be used by a third party advertising SDK to filter the output to only the metadata relevant to its needs. It could define an “Advertiser-ad” `CLASS` with the following attributes:

- `X-ADVERTISER-AD-GUID` (the unique identifier for the ad)
- `X-ADVERTISER-AD-AGE` (the number of days in its inventory)

The SDK could require clients to pass it any player items the app creates so it could configure them to output its needed data as shown below:

```swift
let labels = ["Advertiser-ad"]
metadataCollector = AVPlayerItemMetadataCollector(identifiers: nil,
                                                  classifyingLabels: labels)
metadataCollector.setDelegate(self, queue: DispatchQueue(label: "ad_queue"))
clientProvidedPlayerItem.add(metadataCollector)
```

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)