Meet MusicKit for Swift

RSS for tag

Discuss the WWDC21 session Meet MusicKit for Swift.

View Session

Posts under wwdc21-10294 tag

10 results found
Sort by:
Post not yet marked as solved
60 Views

MusicCatalogSearchRequest without AppleID/Account on iPhone

Hi, I'm currently working on a little music app PoC. I want to search the albums in the Apple Music Catalog which will done via a MusicCatalogSearchRequest: let musicAuthorizationStatus = await MusicAuthorization.request() print(musicAuthorizationStatus) // Issue a catalog search request for albums matching search term. var searchRequest = MusicCatalogSearchRequest(term: searchTerm, types: [Album.self]) searchRequest.limit = 5 let searchResponse = try? await searchRequest.response() print(searchResponse?.albums) I would expect to get a valid search response but it is nil instead. This is the console log when no AppleID is configured on my test device: 2021-06-15 23:07:19.083194+0200 ShareFi[1519:727518] [Entitlements] MSVEntitlementUtilities - Process ShareFi PID[1519] - Group: com.apple.private.tcc.allow - Entitlement: kTCCServiceMediaLibrary - Entitled: NO - Error: (null) .authorized 2021-06-15 23:07:19.130446+0200 ShareFi[1519:727542] [DataRequesting] Failed retrieving MusicKit tokens: Error Domain=ICErrorDomain Code=-8102 "Failed to fetch user token." UserInfo={NSDebugDescription=Failed to fetch user token., NSUnderlyingError=0x2825d8750 {Error Domain=ICErrorDomain Code=-7401 "No active account." UserInfo={NSDebugDescription=No active account.}}}. Throwing .userTokenRequestFailed. 2021-06-15 23:07:19.131133+0200 ShareFi[1519:727542] [DataRequesting] Failed retrieving tokens for MusicDataRequest.Context(url: https://api.music.apple.com/v1/catalog/us/search?term=Earfood&types=albums&omit%5Bresource%5D=autos&limit=5). Error = .userTokenRequestFailed. When I use a sandbox account the error is still a .userTokenRequestFailed but the message says something like: Privacy terms must be accepted first. The Apple Music API seems to require a "Developer Token" but no "User Token" for search requests?! So my questions are: Is it possible to make MusicCatalogSearchRequests without having an AppleID configured? What resources can a user without a active Apple Music subscription interact with? Best regards :) Julian
Asked
by juka1205.
Last updated
.
Post not yet marked as solved
38 Views

Use Audio Engine with MusicKit players "ApplicationMusicPlayer" or "SystemMusicPlayer"

I want to use AudioEngine to process audio and apply sound effects like reverberation, EQ, compressor, limiter and get more fun with favorite songs. I want to build this on top of MusicKit, ideally using SystemMusicPlayer. is there a way to process this output from SystemMusicPlayer over AudioEngine?
Asked
by typan112.
Last updated
.
Post not yet marked as solved
31 Views

Find songs by Beats Per Minute

Is it possible to search for songs by beats per minute? If so, how? The WWDC session mentioned a fitness app playing upbeat music to keep a user motivated during a workout. I'd like to let the user search for music at a certain tempo or range of tempos to find music appropriate for sections of a workout. Is this possible?
Asked Last updated
.
Post not yet marked as solved
129 Views

MusicKit: developer token request failed

The MusicKit video states that you just enable "MusicKit" in your application identifier and "you're done!" Ok, so I did that, and I'm seeing the following error when trying to run a song query: [DataRequesting] Failed retrieving MusicKit tokens: Error Domain=ICErrorDomain Code=-8200 "Media API Token Service's response was invalid (status code: Unauthorized (401))." UserInfo={NSDebugDescription=Media API Token Service's response was invalid (status code: Unauthorized (401))., NSUnderlyingError=0x6000023a0c60 {Error Domain=AMSErrorDomain Code=301 "Invalid Status Code" UserInfo={NSLocalizedDescription=Invalid Status Code, AMSURL=https://sf-api-token-service.itunes.apple.com/apiToken?REDACTED, AMSStatusCode=401, AMSServerPayload={ status = verificationFailure; }, NSLocalizedFailureReason=The response has an invalid status code}}}. Throwing .developerTokenRequestFailed. Is this just broken on Apple's side? Is there some other magic string that needs to be added to the plist other than NSAppleMusicUsageDescription?
Asked
by xinsight.
Last updated
.
Post not yet marked as solved
59 Views

Error: connection to service on pid 0 named com.apple.itunescloudd.xpc

I am following along the session Meet MusicKit, and when I try to call this snippet of code (directly copied from session): struct MyGenresResponse: Decodable {             let data: [Genre]         }         let countryCode = try await MusicDataRequest.currentCountryCode         let url = URL(string: "https://api.music.apple.com/v1/catalog/\(countryCode)/genres")!         let dataRequest = MusicDataRequest(urlRequest: URLRequest(url: url))         let dataResponse = try await dataRequest.response()         let decoder = JSONDecoder()         let genresResponse = try decoder.decode(MyGenresResponse.self, from: dataResponse.data)         print("\(genresResponse.data[9])") I run into a problem. The code is not working as intended and the console gives me an error that looks like: I have registered an AppID for my app and enabled MusicKit capability. 2021-06-10 16:43:23.166876-0700 MusicPlayground[1179:93172] [Default] <ICCloudServerListenerEndpointProvider: 0x281f6a960>: listenerEndpointForService - XPC Error retrieving endpoint [Attempt 1 of 10] - service=cloudStatusMonitor[4] - error=Error Domain=NSCocoaErrorDomain Code=4097 "connection to service on pid 0 named com.apple.itunescloudd.xpc" UserInfo={NSDebugDescription=connection to service on pid 0 named com.apple.itunescloudd.xpc} 2021-06-10 16:43:23.174082-0700 MusicPlayground[1179:93172] [Default] <ICCloudServerListenerEndpointProvider: 0x281f6a960>: listenerEndpointForService - XPC Error retrieving endpoint [Attempt 2 of 10] - service=cloudStatusMonitor[4] - error=Error Domain=NSCocoaErrorDomain Code=4097 "connection to service on pid 0 named com.apple.itunescloudd.xpc" UserInfo={NSDebugDescription=connection to service on pid 0 named com.apple.itunescloudd.xpc} 2021-06-10 16:43:23.181243-0700 MusicPlayground[1179:93172] [Default] <ICCloudServerListenerEndpointProvider: 0x281f6a960>: listenerEndpointForService - XPC Error retrieving endpoint [Attempt 3 of 10] - service=cloudStatusMonitor[4] - error=Error Domain=NSCocoaErrorDomain Code=4097 "connection to service on pid 0 named com.apple.itunescloudd.xpc" UserInfo={NSDebugDescription=connection to service on pid 0 named com.apple.itunescloudd.xpc} 2021-06-10 16:43:23.183420-0700 MusicPlayground[1179:93172] [Default] <ICCloudServerListenerEndpointProvider: 0x281f6a960>: listenerEndpointForService - XPC Error retrieving endpoint [Attempt 4 of 10] - service=cloudStatusMonitor[4] - error=Error Domain=NSCocoaErrorDomain Code=4097 "connection to service on pid 0 named com.apple.itunescloudd.xpc" UserInfo={NSDebugDescription=connection to service on pid 0 named com.apple.itunescloudd.xpc} 2021-06-10 16:43:23.184647-0700 MusicPlayground[1179:93172] [Default] <ICCloudServerListenerEndpointProvider: 0x281f6a960>: listenerEndpointForService - XPC Error retrieving endpoint [Attempt 5 of 10] - service=cloudStatusMonitor[4] - error=Error Domain=NSCocoaErrorDomain Code=4097 "connection to service on pid 0 named com.apple.itunescloudd.xpc" UserInfo={NSDebugDescription=connection to service on pid 0 named com.apple.itunescloudd.xpc} 2021-06-10 16:43:23.187290-0700 MusicPlayground[1179:93172] [Default] <ICCloudServerListenerEndpointProvider: 0x281f6a960>: listenerEndpointForService - XPC Error retrieving endpoint [Attempt 6 of 10] - service=cloudStatusMonitor[4] - error=Error Domain=NSCocoaErrorDomain Code=4097 "connection to service on pid 0 named com.apple.itunescloudd.xpc" UserInfo={NSDebugDescription=connection to service on pid 0 named com.apple.itunescloudd.xpc} 2021-06-10 16:43:23.190262-0700 MusicPlayground[1179:93172] [Default] <ICCloudServerListenerEndpointProvider: 0x281f6a960>: listenerEndpointForService - XPC Error retrieving endpoint [Attempt 7 of 10] - service=cloudStatusMonitor[4] - error=Error Domain=NSCocoaErrorDomain Code=4097 "connection to service on pid 0 named com.apple.itunescloudd.xpc" UserInfo={NSDebugDescription=connection to service on pid 0 named com.apple.itunescloudd.xpc} 2021-06-10 16:43:23.192981-0700 MusicPlayground[1179:93172] [Default] <ICCloudServerListenerEndpointProvider: 0x281f6a960>: listenerEndpointForService - XPC Error retrieving endpoint [Attempt 8 of 10] - service=cloudStatusMonitor[4] - error=Error Domain=NSCocoaErrorDomain Code=4097 "connection to service on pid 0 named com.apple.itunescloudd.xpc" UserInfo={NSDebugDescription=connection to service on pid 0 named com.apple.itunescloudd.xpc} 2021-06-10 16:43:23.194085-0700 MusicPlayground[1179:93172] [Default] <ICCloudServerListenerEndpointProvider: 0x281f6a960>: listenerEndpointForService - XPC Error retrieving endpoint [Attempt 9 of 10] - service=cloudStatusMonitor[4] - error=Error Domain=NSCocoaErrorDomain Code=4097 "connection to service on pid 0 named com.apple.itunescloudd.xpc" UserInfo={NSDebugDescription=connection to service on pid 0 named com.apple.itunescloudd.xpc} 2021-06-10 16:43:23.195300-0700 MusicPlayground[1179:93172] [Default] <ICCloudServerListenerEndpointProvider: 0x281f6a960>: listenerEndpointForService - XPC Error retrieving endpoint [Attempt 10 of 10] - service=cloudStatusMonitor[4] - error=Error Domain=NSCocoaErrorDomain Code=4097 "connection to service on pid 0 named com.apple.itunescloudd.xpc" UserInfo={NSDebugDescription=connection to service on pid 0 named com.apple.itunescloudd.xpc} 2021-06-10 16:43:23.195354-0700 MusicPlayground[1179:93172] [Default] <ICCloudServerListenerEndpointProvider: 0x281f6a960>: listenerEndpointForService [done with error] - service=cloudStatusMonitor[4] - endpoint=(null) - error=Error Domain=NSCocoaErrorDomain Code=4097 "connection to service on pid 0 named com.apple.itunescloudd.xpc" UserInfo={NSDebugDescription=connection to service on pid 0 named com.apple.itunescloudd.xpc} 2021-06-10 16:43:23.196135-0700 MusicPlayground[1179:93172] [Default] <ICCloudServiceStatusMonitor: 0x28313a300>: Encountered error while requesting storefront country code. Error Domain=ICErrorDomain Code=-7010 "Failed to get listener endpoint for cloud service status monitor." UserInfo={NSDebugDescription=Failed to get listener endpoint for cloud service status monitor., NSUnderlyingError=0x281144750 {Error Domain=NSCocoaErrorDomain Code=4097 "connection to service on pid 0 named com.apple.itunescloudd.xpc" UserInfo={NSDebugDescription=connection to service on pid 0 named com.apple.itunescloudd.xpc}}} Underlying error: Error Domain=NSCocoaErrorDomain Code=4097 "connection to service on pid 0 named com.apple.itunescloudd.xpc" UserInfo={NSDebugDescription=connection to service on pid 0 named com.apple.itunescloudd.xpc}. .permissionDenied
Asked
by jevonmao1.
Last updated
.
Post not yet marked as solved
66 Views

MusicKit Album Release Data

When printing out an Album, the release date is included: Album(   id: "1566393640",   title: "Aquatic - Single",   artistName: "Nora En Pure",   genreNames: [     "Dance",     "Music"   ],   releaseDate: "2021-06-04",   isCompilation: false,   upc: "7640130765399" ) But it is not mentioned as an instance property here and I cannot identify any way to access it in my project. How can I go about getting access to this attribute via MusicKit? Thanks! :)
Asked Last updated
.
Post marked as solved
103 Views

MusicCatalogResourceRequest<MusicKit.Artist> Result Missing Instance Properties

Hello! I am trying a basic MusicCatalogResourceRequest to pull in a particular Artist from Apple Music. When printing out the result, it only contains the id and name of the Artist; ex : Artist(id: "78011850", name: "deadmau5") It is missing all of the instance properties as defined on the developer documentation. This is the snippet I am using, is there something missing? I am trying to fetch the related albums, but it is always returning nil. static func catalogAlbumsForArtistId(artistId: MusicItemID) async -> MusicItemCollection<MusicKit.Album>? { do {         let artistRequest = MusicCatalogResourceRequest<MusicKit.Artist>(matching: \.id, equalTo: artistId)         let artistResponse = try await artistRequest.response()         if let artist = artistResponse.items.first {             print("artist")             return artist.albums         }     } catch {         print(error)     }     return nil } Thanks! :)
Asked Last updated
.
Post marked as solved
81 Views

How can add songs to a playlist or create a new playlist from my APP?

Hi, I would like to be able to create a playlist from my app or add songs to an existing selected playlist in the user music library, How can I do that ? Is there an API in MusicKit to do that? The Shazam app is doing something similar with the My Shazam Songs playlist... Thanks
Asked
by aleroot.
Last updated
.
Post not yet marked as solved
72 Views

Dolby Atmos and Lossless labels

Is there a way to show the these labels in our own applications? If so, is this something we can search on and filter on?
Asked Last updated
.