<!--
{
  "availability" : [
    "iOS: 15.0.0 -",
    "iPadOS: 15.0.0 -",
    "macCatalyst: 15.0.0 -",
    "macOS: 12.0.0 -",
    "tvOS: 15.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 8.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "ShazamKit",
  "identifier" : "/documentation/ShazamKit/SHMediaItem",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "ShazamKit"
    ],
    "preciseIdentifier" : "c:objc(cs)SHMediaItem"
  },
  "title" : "SHMediaItem"
}
-->

# SHMediaItem

An object that represents the metadata for a reference signature.

```
class SHMediaItem
```

## Overview

This class uses subscripting for the data elements of a custom media item that an existing property doesn’t already represent.

Add a readable custom property by extending [`SHMediaItemProperty`](/documentation/ShazamKit/SHMediaItemProperty) with a key for that property, and by extending this class with a property that uses the key. The following code shows the extensions for an episode number:

```swift
// Add an episode number to the list of properties.
extension SHMediaItemProperty {
    static let episode = SHMediaItemProperty("Episode")
}

// Add a property for returning the episode number using a subscript.
extension SHMediaItem {
    var episode: Int? {
        return self[.episode] as? Int
    }
}
```

Add your custom property when you create the media item as the following code shows:

```swift
// Create a new media item and set the title, subtitle, and episode properties.
let mediaItem = SHMediaItem(properties: [.episode: 42,
                                         .title: "Question",
                                         .subtitle: "The Answer"])
```

> Note:
> The class of the object that represents a custom object must be one of: `Dictionary`, `Array`, `URL`, `Number`, `String`, `Date`, or `Data`.

## Topics

### Creating a new media item object

[`init(properties:)`](/documentation/ShazamKit/SHMediaItem/init(properties:))

Creates a media item object with a dictionary of properties and their associated values.

[`+  mediaItemWithProperties:`](/documentation/ShazamKit/SHMediaItem/mediaItemWithProperties:)

Creates a media item object with a dictionary of properties and their associated values.

### Working with media item properties

[`-  objectForKeyedSubscript:`](/documentation/ShazamKit/SHMediaItem/subscript(_:))

Accesses the property for the specified key for reading.

[`-  valueForProperty:`](/documentation/ShazamKit/SHMediaItem/valueForProperty:)

Accesses the property for the specified key for reading.

[`SHMediaItemProperty`](/documentation/ShazamKit/SHMediaItemProperty)

Constants for the media item property names.

[`timeRanges`](/documentation/ShazamKit/SHMediaItem/timeRanges-8msna)

An array of ranges that indicate the offsets within the reference signature that this media item describes.

[`frequencySkewRanges`](/documentation/ShazamKit/SHMediaItem/frequencySkewRanges-1j7d3)

An array of ranges that indicate the frequency skews in the reference signature that this media item describes.

[`timeRanges`](/documentation/ShazamKit/SHMediaItem/timeRanges-43654)

An array of ranges that indicate the offsets within the reference signature that this media item describes.

[`frequencySkewRanges`](/documentation/ShazamKit/SHMediaItem/frequencySkewRanges-4yqx)

An array of ranges that indicate the frequency skews in the reference signature that this media item describes.

[`SHRange`](/documentation/ShazamKit/SHRange)

A half-open interval from a lower bound up to, but not including, an upper bound.

### Reading general media item properties

[`title`](/documentation/ShazamKit/SHMediaItem/title)

A title for the media item.

[`subtitle`](/documentation/ShazamKit/SHMediaItem/subtitle)

A subtitle for the media item.

[`artist`](/documentation/ShazamKit/SHMediaItem/artist)

The name of the artist for the media item, such as the performer of a song.

[`artworkURL`](/documentation/ShazamKit/SHMediaItem/artworkURL)

The URL for artwork for the media item, such as an album cover.

[`videoURL`](/documentation/ShazamKit/SHMediaItem/videoURL)

The URL for a video for the media item, such as a music video.

[`genres`](/documentation/ShazamKit/SHMediaItem/genres)

An array of genre names for the media item.

[`explicitContent`](/documentation/ShazamKit/SHMediaItem/explicitContent)

A Boolean value that indicates whether the media item contains explicit content.

[`creationDate`](/documentation/ShazamKit/SHMediaItem/creationDate)

The date the media item was created.

[`isrc`](/documentation/ShazamKit/SHMediaItem/isrc)

The International Standard Recording Code (ISRC) for the media item.

[`id`](/documentation/ShazamKit/SHMediaItem/id)

A unique identifier for this media item.

### Reading Apple Music properties

[`songs`](/documentation/ShazamKit/SHMediaItem/songs)

An array of MusicKit song objects that represent the song.

[`appleMusicURL`](/documentation/ShazamKit/SHMediaItem/appleMusicURL)

A link to the Apple Music page that contains the full information for the song.

[`appleMusicID`](/documentation/ShazamKit/SHMediaItem/appleMusicID)

The Apple Music ID for the song.

### Working with Shazam music catalog media items

[`webURL`](/documentation/ShazamKit/SHMediaItem/webURL)

A link to the Shazam Music catalog page that contains the full information for the song.

[`shazamID`](/documentation/ShazamKit/SHMediaItem/shazamID)

The Shazam ID for the song.

[`+  fetchMediaItemWithShazamID:completionHandler:`](/documentation/ShazamKit/SHMediaItem/fetch(shazamID:completionHandler:))

Requests the media item for the song with the specified Shazam ID.

## Relationships

### Conforms To

[`NSObjectProtocol`](/documentation/ObjectiveC/NSObjectProtocol)

[`Sendable`](/documentation/Swift/Sendable)

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

[`Copyable`](/documentation/Swift/Copyable)

[`CVarArg`](/documentation/Swift/CVarArg)

[`Escapable`](/documentation/Swift/Escapable)

[`Identifiable`](/documentation/Swift/Identifiable)

[`CustomDebugStringConvertible`](/documentation/Swift/CustomDebugStringConvertible)

[`Equatable`](/documentation/Swift/Equatable)

[`NSCoding`](/documentation/Foundation/NSCoding)

[`Hashable`](/documentation/Swift/Hashable)

[`CustomStringConvertible`](/documentation/Swift/CustomStringConvertible)

[`NSSecureCoding`](/documentation/Foundation/NSSecureCoding)

[`NSCopying`](/documentation/Foundation/NSCopying)

### Inherited By

[`SHMatchedMediaItem`](/documentation/ShazamKit/SHMatchedMediaItem)

### Inherits From

[`NSObject-swift.class`](/documentation/ObjectiveC/NSObject-swift.class)

---

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)