objc2_shazam_kit/generated/SHMediaItem.rs
1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6use objc2_foundation::*;
7
8use crate::*;
9
10/// Constants for the media item property names.
11///
12/// See also [Apple's documentation](https://developer.apple.com/documentation/shazamkit/shmediaitemproperty?language=objc)
13// NS_TYPED_EXTENSIBLE_ENUM
14pub type SHMediaItemProperty = NSString;
15
16extern "C" {
17 /// The Shazam media ID
18 ///
19 /// See also [Apple's documentation](https://developer.apple.com/documentation/shazamkit/shmediaitemshazamid?language=objc)
20 pub static SHMediaItemShazamID: &'static SHMediaItemProperty;
21}
22
23extern "C" {
24 /// Title
25 ///
26 /// See also [Apple's documentation](https://developer.apple.com/documentation/shazamkit/shmediaitemtitle?language=objc)
27 pub static SHMediaItemTitle: &'static SHMediaItemProperty;
28}
29
30extern "C" {
31 /// Subtitle
32 ///
33 /// See also [Apple's documentation](https://developer.apple.com/documentation/shazamkit/shmediaitemsubtitle?language=objc)
34 pub static SHMediaItemSubtitle: &'static SHMediaItemProperty;
35}
36
37extern "C" {
38 /// Artist
39 ///
40 /// See also [Apple's documentation](https://developer.apple.com/documentation/shazamkit/shmediaitemartist?language=objc)
41 pub static SHMediaItemArtist: &'static SHMediaItemProperty;
42}
43
44extern "C" {
45 /// A web URL representing this result
46 ///
47 /// See also [Apple's documentation](https://developer.apple.com/documentation/shazamkit/shmediaitemweburl?language=objc)
48 pub static SHMediaItemWebURL: &'static SHMediaItemProperty;
49}
50
51extern "C" {
52 /// The AppleMusic ID
53 ///
54 /// See also [Apple's documentation](https://developer.apple.com/documentation/shazamkit/shmediaitemapplemusicid?language=objc)
55 pub static SHMediaItemAppleMusicID: &'static SHMediaItemProperty;
56}
57
58extern "C" {
59 /// A link to this media on Apple Music
60 ///
61 /// See also [Apple's documentation](https://developer.apple.com/documentation/shazamkit/shmediaitemapplemusicurl?language=objc)
62 pub static SHMediaItemAppleMusicURL: &'static SHMediaItemProperty;
63}
64
65extern "C" {
66 /// A URL to the artwork
67 ///
68 /// See also [Apple's documentation](https://developer.apple.com/documentation/shazamkit/shmediaitemartworkurl?language=objc)
69 pub static SHMediaItemArtworkURL: &'static SHMediaItemProperty;
70}
71
72extern "C" {
73 /// A URL for a Video associated with the media
74 ///
75 /// See also [Apple's documentation](https://developer.apple.com/documentation/shazamkit/shmediaitemvideourl?language=objc)
76 pub static SHMediaItemVideoURL: &'static SHMediaItemProperty;
77}
78
79extern "C" {
80 /// Is this content explicit
81 ///
82 /// See also [Apple's documentation](https://developer.apple.com/documentation/shazamkit/shmediaitemexplicitcontent?language=objc)
83 pub static SHMediaItemExplicitContent: &'static SHMediaItemProperty;
84}
85
86extern "C" {
87 /// An array of strings representing the genres of the media item
88 ///
89 /// See also [Apple's documentation](https://developer.apple.com/documentation/shazamkit/shmediaitemgenres?language=objc)
90 pub static SHMediaItemGenres: &'static SHMediaItemProperty;
91}
92
93extern "C" {
94 /// The International Standard Recording Code
95 ///
96 /// See also [Apple's documentation](https://developer.apple.com/documentation/shazamkit/shmediaitemisrc?language=objc)
97 pub static SHMediaItemISRC: &'static SHMediaItemProperty;
98}
99
100extern "C" {
101 /// The key to access the time ranges property of a media item.
102 ///
103 /// See also [Apple's documentation](https://developer.apple.com/documentation/shazamkit/shmediaitemtimeranges?language=objc)
104 pub static SHMediaItemTimeRanges: &'static SHMediaItemProperty;
105}
106
107extern "C" {
108 /// The key to access the frequency skew ranges property of a media item.
109 ///
110 /// See also [Apple's documentation](https://developer.apple.com/documentation/shazamkit/shmediaitemfrequencyskewranges?language=objc)
111 pub static SHMediaItemFrequencySkewRanges: &'static SHMediaItemProperty;
112}
113
114extern "C" {
115 /// The date when the media item was created
116 ///
117 /// See also [Apple's documentation](https://developer.apple.com/documentation/shazamkit/shmediaitemcreationdate?language=objc)
118 pub static SHMediaItemCreationDate: &'static SHMediaItemProperty;
119}
120
121extern_class!(
122 /// An object that represents the metadata for a reference signature.
123 ///
124 /// This class uses subscripting for the data elements of a custom media item that an existing property doesn't already represent.
125 ///
126 /// Add a readable custom property by extending ``SHMediaItemProperty-struct`` 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:
127 ///
128 /// ```swift
129 /// // Add an episode number to the list of properties.
130 /// extension SHMediaItemProperty {
131 /// static let episode = SHMediaItemProperty("Episode")
132 /// }
133 ///
134 /// // Add a property for returning the episode number using a subscript.
135 /// extension SHMediaItem {
136 /// var episode: Int? {
137 /// return self[.episode] as? Int
138 /// }
139 /// }
140 /// ```
141 ///
142 /// Add your custom property when you create the media item as the following code shows:
143 ///
144 /// ```swift
145 /// // Create a new media item and set the title, subtitle, and episode properties.
146 /// let mediaItem = SHMediaItem(properties: [.episode: 42,
147 /// .title: "Question",
148 /// .subtitle: "The Answer"])
149 /// ```
150 ///
151 /// > Note:
152 /// > The class of the object that represents a custom object must be one of: `Dictionary`, `Array`, `URL`, `Number`, `String`, `Date`, or `Data`.
153 ///
154 /// See also [Apple's documentation](https://developer.apple.com/documentation/shazamkit/shmediaitem?language=objc)
155 #[unsafe(super(NSObject))]
156 #[derive(Debug, PartialEq, Eq, Hash)]
157 pub struct SHMediaItem;
158);
159
160unsafe impl Send for SHMediaItem {}
161
162unsafe impl Sync for SHMediaItem {}
163
164extern_conformance!(
165 unsafe impl NSCoding for SHMediaItem {}
166);
167
168extern_conformance!(
169 unsafe impl NSCopying for SHMediaItem {}
170);
171
172unsafe impl CopyingHelper for SHMediaItem {
173 type Result = Self;
174}
175
176extern_conformance!(
177 unsafe impl NSObjectProtocol for SHMediaItem {}
178);
179
180extern_conformance!(
181 unsafe impl NSSecureCoding for SHMediaItem {}
182);
183
184impl SHMediaItem {
185 extern_methods!(
186 /// The Shazam ID for the song.
187 #[unsafe(method(shazamID))]
188 #[unsafe(method_family = none)]
189 pub unsafe fn shazamID(&self) -> Option<Retained<NSString>>;
190
191 /// A title for the media item.
192 #[unsafe(method(title))]
193 #[unsafe(method_family = none)]
194 pub unsafe fn title(&self) -> Option<Retained<NSString>>;
195
196 /// A subtitle for the media item.
197 #[unsafe(method(subtitle))]
198 #[unsafe(method_family = none)]
199 pub unsafe fn subtitle(&self) -> Option<Retained<NSString>>;
200
201 /// The name of the artist for the media item, such as the performer of a song.
202 #[unsafe(method(artist))]
203 #[unsafe(method_family = none)]
204 pub unsafe fn artist(&self) -> Option<Retained<NSString>>;
205
206 /// An array of genre names for the media item.
207 ///
208 /// The array is empty if there are no media items.
209 #[unsafe(method(genres))]
210 #[unsafe(method_family = none)]
211 pub unsafe fn genres(&self) -> Retained<NSArray<NSString>>;
212
213 /// The Apple Music ID for the song.
214 #[unsafe(method(appleMusicID))]
215 #[unsafe(method_family = none)]
216 pub unsafe fn appleMusicID(&self) -> Option<Retained<NSString>>;
217
218 /// A link to the Apple Music page that contains the full information for the song.
219 #[unsafe(method(appleMusicURL))]
220 #[unsafe(method_family = none)]
221 pub unsafe fn appleMusicURL(&self) -> Option<Retained<NSURL>>;
222
223 /// A link to the Shazam Music catalog page that contains the full information for the song.
224 ///
225 /// This link opens the Shazam app or App Clip if it's available on the device.
226 #[unsafe(method(webURL))]
227 #[unsafe(method_family = none)]
228 pub unsafe fn webURL(&self) -> Option<Retained<NSURL>>;
229
230 /// The URL for artwork for the media item, such as an album cover.
231 #[unsafe(method(artworkURL))]
232 #[unsafe(method_family = none)]
233 pub unsafe fn artworkURL(&self) -> Option<Retained<NSURL>>;
234
235 /// The URL for a video for the media item, such as a music video.
236 #[unsafe(method(videoURL))]
237 #[unsafe(method_family = none)]
238 pub unsafe fn videoURL(&self) -> Option<Retained<NSURL>>;
239
240 /// A Boolean value that indicates whether the media item contains explicit content.
241 #[unsafe(method(explicitContent))]
242 #[unsafe(method_family = none)]
243 pub unsafe fn explicitContent(&self) -> bool;
244
245 /// The International Standard Recording Code (ISRC) for the media item.
246 #[unsafe(method(isrc))]
247 #[unsafe(method_family = none)]
248 pub unsafe fn isrc(&self) -> Option<Retained<NSString>>;
249
250 #[cfg(feature = "SHRange")]
251 /// An array of ranges that indicate the offsets within the reference signature that this media item describes.
252 #[unsafe(method(timeRanges))]
253 #[unsafe(method_family = none)]
254 pub unsafe fn timeRanges(&self) -> Retained<NSArray<SHRange>>;
255
256 #[cfg(feature = "SHRange")]
257 /// An array of ranges that indicate the frequency skews in the reference signature that this media item describes.
258 #[unsafe(method(frequencySkewRanges))]
259 #[unsafe(method_family = none)]
260 pub unsafe fn frequencySkewRanges(&self) -> Retained<NSArray<SHRange>>;
261
262 /// The date the media item was created.
263 #[unsafe(method(creationDate))]
264 #[unsafe(method_family = none)]
265 pub unsafe fn creationDate(&self) -> Option<Retained<NSDate>>;
266
267 /// Creates a media item object with a dictionary of properties and their associated values.
268 ///
269 /// - Parameters:
270 /// - properties: A dictionary that contains the media item properties and their associated values.
271 ///
272 /// # Safety
273 ///
274 /// `properties` generic should be of the correct type.
275 #[unsafe(method(mediaItemWithProperties:))]
276 #[unsafe(method_family = none)]
277 pub unsafe fn mediaItemWithProperties(
278 properties: &NSDictionary<SHMediaItemProperty, AnyObject>,
279 ) -> Retained<Self>;
280
281 #[cfg(feature = "block2")]
282 /// Requests the media item for the song with the specified Shazam ID.
283 ///
284 /// > Important:
285 /// > You can call this method from synchronous code using a completion handler, as shown on this page, or you can call it as an asynchronous method that has the following declaration:
286 /// >
287 /// > ```swift
288 /// > class func fetch(shazamID: String) async throws -> SHMediaItem
289 /// > ```
290 /// >
291 /// > For information about concurrency and asynchronous code in Swift, see
292 /// <doc
293 /// ://com.apple.documentation/documentation/swift/calling-objective-c-apis-asynchronously>.
294 ///
295 /// - Parameters:
296 /// - shazamID: The Shazam ID of the song.
297 /// - completionHandler: The completion handler that the system calls with the result of the request.
298 ///
299 /// This block takes the following parameters:
300 ///
301 /// - term `mediaItem`: A media item.
302 /// - term `error`: An error object if a problem occurs when fetching the media item; otherwise, `nil`.
303 ///
304 /// # Safety
305 ///
306 /// `completion_handler` block must be sendable.
307 #[unsafe(method(fetchMediaItemWithShazamID:completionHandler:))]
308 #[unsafe(method_family = none)]
309 pub unsafe fn fetchMediaItemWithShazamID_completionHandler(
310 shazam_id: &NSString,
311 completion_handler: &block2::DynBlock<dyn Fn(*mut SHMediaItem, *mut NSError)>,
312 );
313
314 /// Accesses the property for the specified key for reading.
315 ///
316 /// - Parameters:
317 /// - property: The key for the property.
318 ///
319 /// - Returns: The value of the property; otherwise, `nil`.
320 #[unsafe(method(valueForProperty:))]
321 #[unsafe(method_family = none)]
322 pub unsafe fn valueForProperty(
323 &self,
324 property: &SHMediaItemProperty,
325 ) -> Retained<AnyObject>;
326
327 /// Accesses the property for the specified key for reading.
328 ///
329 /// - Parameters:
330 /// - key: The key for the media item property.
331 ///
332 /// - Returns: The value of the property; otherwise, `nil`.
333 #[unsafe(method(objectForKeyedSubscript:))]
334 #[unsafe(method_family = none)]
335 pub unsafe fn objectForKeyedSubscript(
336 &self,
337 key: &SHMediaItemProperty,
338 ) -> Retained<AnyObject>;
339
340 #[unsafe(method(new))]
341 #[unsafe(method_family = new)]
342 pub unsafe fn new() -> Retained<Self>;
343
344 #[unsafe(method(init))]
345 #[unsafe(method_family = init)]
346 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
347 );
348}