@@ -124,53 +124,29 @@ let acoustID = AcoustID(apiKey: "zfkYWDrOqAk", timeout: 10.0)
124
124
Lookup an AudioFingerprint object
125
125
126
126
``` swift
127
- acoustID.lookup (newFingerprint) { response in
128
- switch response {
129
- case .failure (let error):
130
- // AcoustID.Error
131
- case .success (let results):
132
- // [AcoustID.APIResult]
133
- for result in results {
134
- // Matching score (0.0 to 1.0)
135
- let score = result.score
136
-
137
- for recording in result.recordings! {
138
- // Song title
139
- let title = recording.title
140
-
141
- // Song artists
142
- let artists = recording.artists
143
-
144
- // Song release groups (Albums, Singles, etc.)
145
- let releasegroups = recording.releasegroups
146
- }
127
+ do {
128
+ let results = try await acoustID.lookup (newFingerprint)
129
+ // [AcoustID.APIResult]
130
+ for result in results {
131
+ // Matching score (0.0 to 1.0)
132
+ let score = result.score
133
+ for recording in result.recordings! {
134
+ // Song title
135
+ let title = recording.title
136
+ // Song artists
137
+ let artists = recording.artists
138
+ // Song release groups (Albums, Singles, etc.)
139
+ let releasegroups = recording.releasegroups
147
140
}
148
141
}
149
- }
150
- ```
151
-
152
- ### Handling errors
153
-
154
- Throwing calls throw either an ` AudioDecoder.Error `
155
-
156
- ``` swift
157
- do {
158
- let fileURL = URL (fileURLWithPath : " Invalid.mp3" )
159
- try AudioFingerprint (from : fileURL)
160
142
} catch {
161
- // AudioDecoder .Error.invalidFile
143
+ // AcoustID .Error
162
144
}
163
145
```
164
146
165
- Or an ` AudioFingerprint.Error `
147
+ ### Handling errors
166
148
167
- ``` swift
168
- do {
169
- try AudioFingerprint (from : " Invalid" , duration : 46.0 )
170
- } catch {
171
- // AudioFingerprint.Error.invalidFingerprint
172
- }
173
- ```
149
+ The ` AudioFingerprint ` class throws either ` AudioDecoder.Error ` or ` AudioFingerprint.Error ` errors, the ` AcoustID ` class throws ` AcoustID.Error ` errors.
174
150
175
151
### Accessing Chromaprints C API
176
152
0 commit comments