Meet MusicKit for Swift

RSS for tag

Discuss the WWDC21 session Meet MusicKit for Swift.

Posts under wwdc21-10294 tag

54 Posts

Post

Replies

Boosts

Views

Activity

How to get the album info for a song fetched by MusicDataRequest?
I'm slowly learning the new MusicKit beta for swift. I've learned to successfully retrieve tracks of type Song using MusicDataRequest, using the following: ... let countryCode = try await MusicDataRequest.currentCountryCode if let url = URL(string: "https://api.music.apple.com/v1/catalog/\(countryCode)/songs?filter[isrc]=\(isrc)") {   let dataRequest = MusicDataRequest(urlRequest: URLRequest(url: url))   let dataResponse = try await dataRequest.response() ... However, when I decode the data, there does not seem to be any album information that I can see. I've tried adding includes=albums to the URL, but I don't think that's the right approach, because when I veiw the Song struct in MusicKit, I don't see a reference to an Album type anywhere. Any advice on how to retrieve the album information would be most appreciated. Thanks.
7
0
4k
Apr ’24
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?
7
0
4.9k
Mar ’24
How can I play Apple Music Live Radio Station?
Hello, I'm using systemMusicPlayer to play Apple Music Live Radio Station got from Apple Music API. But it doesn't work. How can I do that? Error: Test[46751:13235249] [SDKPlayback] Failed to prepareToPlay error: Error Domain=MPMusicPlayerControllerErrorDomain Code=6 "Failed to prepare to play" UserInfo={NSDebugDescription=Failed to prepare to play} My implementation:    let musicPlayerController = MPMusicPlayerController.systemMusicPlayer musicPlayerController.beginGeneratingPlaybackNotifications()      musicPlayerController.setQueue(with: "ra.978194965")     musicPlayerController.play() API response: { “id”: “ra.978194965”, “type”: “stations”, “href”: “/v1/catalog/us/stations/ra.978194965”, “attributes”: { “artwork”: { “width”: 4320, “url”: “https://is2-ssl.mzstatic.com/image/thumb/Features114/v4/e5/10/76/e5107683-9e51-ebc5-3901-d8fbd65f2c2a/source/{w}x{h}sr.jpeg”, “height”: 1080, “textColor3”: “332628”, “textColor2”: “120509”, “textColor4”: “33272a”, “textColor1”: “000000”, “bgColor”: “f4f4f4”, “hasP3”: false }, “url”: “https://music.apple.com/us/station/apple-music-1/ra.978194965”, “mediaKind”: “audio”, “supportedDrms”: [ “fairplay”, “playready”, “widevine” ], “requiresSubscription”: false, “name”: “Apple Music 1”, “kind”: “streaming”, “radioUrl”: “itsradio://music.apple.com/us/station/ra.978194965”, “playParams”: { “id”: “ra.978194965”, “kind”: “radioStation”, “format”: “stream”, “stationHash”: “CgkIBRoFlaS40gMQBA”, “mediaType”: 0 }, “editorialNotes”: { “name”: “Apple Music 1”, “short”: “The new music that matters.”, “tagline”: “The new music that matters.” }, “isLive”: true } },``` Thank you! Best regards, MichaelNg
2
0
2.4k
Aug ’23
MusicAlbums simulator recommendation
Hi, MusicKit is a particularly good example for teaching aspects of async coding. The API does many things very nicely. It would be nice if developers could access their Music libraries in the simulator as that would make this API a great teaching tool. Requiring new devs to deploy an app to a device in a workshop is a bit much for some. I have no idea if this is something you can practically enable - but I thought it was worth suggesting. Thanks, Daniel
2
0
1.9k
Aug ’22
Fetching Catalog Top Charts Genres
Hi there! I am working on the genres screen and realised that I can directly use MusicCatalogResourceRequest for fetching genre with a particular ID: func getGenres() async {     do {       let genreID = MusicItemID("17")       let request = MusicCatalogResourceRequest<Genre>(matching: \.id, equalTo: genreID)       let genreResponse = try await request.response()       print(genreResponse.items)     } catch {       print(error)     }   } Apple Music also has an API to get the top charts genres. How would I do it without using MusicDataRequest, or is it the only way? My current approach: typealias Genres = MusicItemCollection<Genre> do { let countryCode = try await MusicDataRequest.currentCountryCode let genreURL = "https://api.music.apple.com/v1/catalog/\(countryCode)/genres" guard let url = URL(string: genreURL) else { throw URLError(.badURL) } let request = MusicDataRequest(urlRequest: URLRequest(url: url)) let response = try await request.response() let genre = try JSONDecoder().decode(Genres.self, from: response.data) print(genre) } catch { print(error) } Thank you!
4
0
1.6k
Jun ’22
latest and top releases of a record label
Hi there! I am trying to fetch a record label's top and latest releases. For example, for "Big Machine Label Group", I can see the top and latest releases on Apple Music. I get the latest and top releases if I use the endpoint to get a catalog record label and query parameters to extend. https://api.music.apple.com/v1/catalog/us/record-labels/1552967199?views=top-releases,latest-releases However, I am getting nil for these values using MusicCatalogResourceRequest. Here's the code: let request = MusicCatalogResourceRequest<RecordLabel>(matching: \.id, equalTo: "1552967199") let response = try await request.response() guard let recordLabel = response.items.first else { return } print(recordLabel.topReleases) print(recordLabel.latestReleases) I cannot add properties for these either to get detailed info because I think there is no PartialMusicProperty when Root is RecordLabel. Can you point me to what I am doing wrong?
4
0
1.6k
Jun ’22
Accessing details about the Curator
Hi there! How do I go about accessing the details of the curator? For example, if I hit the following endpoint to access details about a playlist: https://api.music.apple.com/v1/catalog/us/playlists/pl.047294ae14a24e5993d1f7ab2b127188 Then, in the response, I see the curator containing the ID under relationships: "curator": {  "href": "/v1/catalog/us/playlists/pl.047294ae14a24e5993d1f7ab2b127188/curator",  "data": [   {    "id": "976439548",    "type": "apple-curators",    "href": "/v1/catalog/us/apple-curators/976439548"   }  ] } Using this ID, I can get more information like the editorial notes, kind, artwork, etc. If I use MusicKit to get details about the playlist: let id = MusicItemID("pl.047294ae14a24e5993d1f7ab2b127188") let request = MusicCatalogResourceRequest<Playlist>(matching: \.id, equalTo: id) let response = try await request.response() guard let playlist = response.items.first else { return } print(playlist.curatorName) It does not expose the Curator object but only the curatorName. How can I access the ID of the curator?
3
0
2k
Jun ’22
MusicKit Custom Data Request
Hi, I am trying to use MusicDataRequest from MusicKit to get the user's library artists (https://api.music.apple.com/v1/me/library/artists). This works well, until I am trying to use pagination with it. The data returned by this endpoint contains a "next" property, which reads /v1/me/library/artists?offset=25. Replacing the URL as such resulting in https://api.music.apple.com/v1/me/library/artists?offset=25 no longer works, as the request returns an error: MusicDataRequest.Error( status: 400, code: 40008, title: "Invalid Path Value", detailText: "Unknown library resource type 'artists?offset=25'", ... ) It seems like the request cannot handle query parameters and considers them as part of the request's path. Is there any way to use query parameters with MusicDataRequest? Thanks for any response.
3
0
1.7k
Jun ’22
Using MusicKit to retrieve playlists and contents of playlists
What is the best approach to retrieve playlists using MusicKit. I can't seem to guess from the docs how to use the API to accomplish this, as well as retrieving tracks from a playlist. I am in the process of migrating code from Apple Music API to MusicKit and I potentially could use MusicDataRequest to retrieve playlists using the Apple Music API endpoints, but I want to be sure there are no better alternatives. Sample code would definitely help.
6
0
4.1k
Jun ’22
How to decode the JSON response from MusicKit Search Suggestion
Hello everyone, I am trying to understand how to decode the JSON response returned by the suggestions/top results endpoint in MusicKit As you can see the response returns suggestions, which has two different types, Albums and Songs within the same 'suggestions' array. How can I decode the response even if there are different types using a single struct? { "results" : { "suggestions" : [ { "content" : { "attributes" : { "url" : "https:\/\/music.apple.com\/us\/artist\/megan-thee-stallion\/1258989914", "name" : "Megan Thee Stallion", "genreNames" : [ "Hip-Hop\/Rap" ] }, "id" : "1258989914", "relationships" : { "albums" : { "data" : [ { "href" : "\/v1\/catalog\/us\/albums\/1537889223", "type" : "albums", "id" : "1537889223" } ], "next" : "\/v1\/catalog\/us\/artists\/1258989914\/albums?offset=25", "href" : "\/v1\/catalog\/us\/artists\/1258989914\/albums" } }, "href" : "\/v1\/catalog\/us\/artists\/1258989914", "type" : "artists" }, "kind" : "topResults" }, { "content" : { "href" : "\/v1\/catalog\/us\/artists\/991187319", "attributes" : { "genreNames" : [ "Hip-Hop\/Rap" ], "url" : "https:\/\/music.apple.com\/us\/artist\/moneybagg-yo\/991187319", "name" : "Moneybagg Yo" }, "id" : "991187319", "type" : "artists", "relationships" : { "albums" : { "href" : "\/v1\/catalog\/us\/artists\/991187319\/albums", "data" : [ { "id" : "1550876571", "href" : "\/v1\/catalog\/us\/albums\/1550876571", "type" : "albums" } ], "next" : "\/v1\/catalog\/us\/artists\/991187319\/albums?offset=25" } } }, "kind" : "topResults" } ] } }
5
0
3.3k
Jun ’22
Music preview with MusicKit
Hi, I apologize for asking so many questions. I don't know that I'll ever ship anything but I'm experimenting with an old fashioned radio station like we used to program in the old top forties days. I'd like to allow the music programmers to listen to sets that they're building by skimming through songs - does MusicKit or any part of the API allow us to access the Music preview for a given song? i.e. - I want users with a subscription to be able to hear the 30 s preview that you can find in Music. I may be requesting that a Song have a preview as one of its playing mode options. Thank you, Daniel
9
0
4.6k
Apr ’22
How to make a playlist public/create a public playlist?
Hey everyone, I am creating playlist via the MusicKit API and by default it creates the playlist in the users library and the isPublic attribute is set to false. Is there a way to make the playlist public at the time of creation? (Only way to change isPublic = true at this time seems to be through the Music app right now)
1
0
2.5k
Apr ’22
Get a Catalog Playlist's Relationship Directly by Name
Hi there! I am trying to map the Apple Music API endpoints to MusicKit. For example, I am looking at the catalog playlist endpoints. To get a catalog playlist by its identifier, it is: let request = MusicCatalogResourceRequest<Playlist>(matching: \.id, equalTo: "pl.f4d106fed2bd41149aaacabb233eb5eb") let response = try await request.response() print(response.items) For multiple identifiers, it is:   let request = MusicCatalogResourceRequest<Playlist>(matching: \.id, memberOf: ["pl.f4d106fed2bd41149aaacabb233eb5eb", "pl.4b364b8b182f4115acbf6deb83bd5222"]) let response = try await request.response() print(response.items) To get its relationship like more by curator and featured artists, I can set the properties: var request = MusicCatalogResourceRequest<Playlist>(matching: \.id, equalTo: "pl.f4d106fed2bd41149aaacabb233eb5eb") request.properties = [.featuredArtists, .moreByCurator, .tracks] let response = try await request.response() print(response.items) My question is, how can I map the endpoint Get a Catalog Playlist's Relationship Directly by Name" to MusicKit: https://api.music.apple.com/v1/catalog/{storefront}/playlists/{id}/{relationship} The possible value of the relationship can be curator, library, or tracks. Where can I set these relationship values in the MusicKit request? Thank you!
1
0
1.4k
Apr ’22
Audio trait property in MusicKit
Hi there! I went through the Apple Music API and stumbled upon Get a Catalog Song's Relationship Directly by Name, an endpoint to fetch a song's relationship by using its identifier. If you take a look at the example given on the page: https://api.music.apple.com/v1/catalog/us/songs/1572278914/albums And see the response, it has a property called audioTraits: “audioTraits”: [ “lossy-stereo”, “lossless”, “atmos”, “spatial” ] And another one hasTimeSyncedLyrics: “hasTimeSyncedLyrics”: true Although, I cannot find these two properties in MusicKit's Song. If I hit the API directly using a developer token generated, it does not have these properties as well. I know Apple cannot disclose if these properties will be available in the future or not, but curious nonetheless.
1
0
1.9k
Mar ’22
MusicKit and Export Compliance
Hi, I'm answering the questions on whether or not my app uses encryption. Do calls using MusicKit mean that I have to answer "Yes"? Do these calls qualify for the exemptions referred to in the App Store question: "Does your app qualify for any of the exemptions provided in Category 5, Part 2 of the U.S. Export Administration Regulations?"
1
0
1.5k
Feb ’22
ApplicationMusicPlayer.shared.state.playbackStatus unexpected results
Hi - Of course I may be doing something wrong, but I'm getting exactly the opposite of what I would expect from ApplicationMusicPlayer.shared.state.playbackStatus It returns .playing when the music is paused and .paused when the music is playing. Am I holding it wrong? Thanks, Daniel
Replies
2
Boosts
0
Views
1.5k
Activity
Dec ’24
How to get the album info for a song fetched by MusicDataRequest?
I'm slowly learning the new MusicKit beta for swift. I've learned to successfully retrieve tracks of type Song using MusicDataRequest, using the following: ... let countryCode = try await MusicDataRequest.currentCountryCode if let url = URL(string: "https://api.music.apple.com/v1/catalog/\(countryCode)/songs?filter[isrc]=\(isrc)") {   let dataRequest = MusicDataRequest(urlRequest: URLRequest(url: url))   let dataResponse = try await dataRequest.response() ... However, when I decode the data, there does not seem to be any album information that I can see. I've tried adding includes=albums to the URL, but I don't think that's the right approach, because when I veiw the Song struct in MusicKit, I don't see a reference to an Album type anywhere. Any advice on how to retrieve the album information would be most appreciated. Thanks.
Replies
7
Boosts
0
Views
4k
Activity
Apr ’24
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?
Replies
7
Boosts
0
Views
4.9k
Activity
Mar ’24
So can we develop a music app and release it?
We are afraid that apple will reject the app for sharing the similar functionality with the Apple Music app.
Replies
3
Boosts
0
Views
2.2k
Activity
Sep ’23
How can I play Apple Music Live Radio Station?
Hello, I'm using systemMusicPlayer to play Apple Music Live Radio Station got from Apple Music API. But it doesn't work. How can I do that? Error: Test[46751:13235249] [SDKPlayback] Failed to prepareToPlay error: Error Domain=MPMusicPlayerControllerErrorDomain Code=6 "Failed to prepare to play" UserInfo={NSDebugDescription=Failed to prepare to play} My implementation:    let musicPlayerController = MPMusicPlayerController.systemMusicPlayer musicPlayerController.beginGeneratingPlaybackNotifications()      musicPlayerController.setQueue(with: "ra.978194965")     musicPlayerController.play() API response: { “id”: “ra.978194965”, “type”: “stations”, “href”: “/v1/catalog/us/stations/ra.978194965”, “attributes”: { “artwork”: { “width”: 4320, “url”: “https://is2-ssl.mzstatic.com/image/thumb/Features114/v4/e5/10/76/e5107683-9e51-ebc5-3901-d8fbd65f2c2a/source/{w}x{h}sr.jpeg”, “height”: 1080, “textColor3”: “332628”, “textColor2”: “120509”, “textColor4”: “33272a”, “textColor1”: “000000”, “bgColor”: “f4f4f4”, “hasP3”: false }, “url”: “https://music.apple.com/us/station/apple-music-1/ra.978194965”, “mediaKind”: “audio”, “supportedDrms”: [ “fairplay”, “playready”, “widevine” ], “requiresSubscription”: false, “name”: “Apple Music 1”, “kind”: “streaming”, “radioUrl”: “itsradio://music.apple.com/us/station/ra.978194965”, “playParams”: { “id”: “ra.978194965”, “kind”: “radioStation”, “format”: “stream”, “stationHash”: “CgkIBRoFlaS40gMQBA”, “mediaType”: 0 }, “editorialNotes”: { “name”: “Apple Music 1”, “short”: “The new music that matters.”, “tagline”: “The new music that matters.” }, “isLive”: true } },``` Thank you! Best regards, MichaelNg
Replies
2
Boosts
0
Views
2.4k
Activity
Aug ’23
MusicAlbums simulator recommendation
Hi, MusicKit is a particularly good example for teaching aspects of async coding. The API does many things very nicely. It would be nice if developers could access their Music libraries in the simulator as that would make this API a great teaching tool. Requiring new devs to deploy an app to a device in a workshop is a bit much for some. I have no idea if this is something you can practically enable - but I thought it was worth suggesting. Thanks, Daniel
Replies
2
Boosts
0
Views
1.9k
Activity
Aug ’22
Fetching Catalog Top Charts Genres
Hi there! I am working on the genres screen and realised that I can directly use MusicCatalogResourceRequest for fetching genre with a particular ID: func getGenres() async {     do {       let genreID = MusicItemID("17")       let request = MusicCatalogResourceRequest<Genre>(matching: \.id, equalTo: genreID)       let genreResponse = try await request.response()       print(genreResponse.items)     } catch {       print(error)     }   } Apple Music also has an API to get the top charts genres. How would I do it without using MusicDataRequest, or is it the only way? My current approach: typealias Genres = MusicItemCollection<Genre> do { let countryCode = try await MusicDataRequest.currentCountryCode let genreURL = "https://api.music.apple.com/v1/catalog/\(countryCode)/genres" guard let url = URL(string: genreURL) else { throw URLError(.badURL) } let request = MusicDataRequest(urlRequest: URLRequest(url: url)) let response = try await request.response() let genre = try JSONDecoder().decode(Genres.self, from: response.data) print(genre) } catch { print(error) } Thank you!
Replies
4
Boosts
0
Views
1.6k
Activity
Jun ’22
latest and top releases of a record label
Hi there! I am trying to fetch a record label's top and latest releases. For example, for "Big Machine Label Group", I can see the top and latest releases on Apple Music. I get the latest and top releases if I use the endpoint to get a catalog record label and query parameters to extend. https://api.music.apple.com/v1/catalog/us/record-labels/1552967199?views=top-releases,latest-releases However, I am getting nil for these values using MusicCatalogResourceRequest. Here's the code: let request = MusicCatalogResourceRequest<RecordLabel>(matching: \.id, equalTo: "1552967199") let response = try await request.response() guard let recordLabel = response.items.first else { return } print(recordLabel.topReleases) print(recordLabel.latestReleases) I cannot add properties for these either to get detailed info because I think there is no PartialMusicProperty when Root is RecordLabel. Can you point me to what I am doing wrong?
Replies
4
Boosts
0
Views
1.6k
Activity
Jun ’22
Accessing details about the Curator
Hi there! How do I go about accessing the details of the curator? For example, if I hit the following endpoint to access details about a playlist: https://api.music.apple.com/v1/catalog/us/playlists/pl.047294ae14a24e5993d1f7ab2b127188 Then, in the response, I see the curator containing the ID under relationships: "curator": {  "href": "/v1/catalog/us/playlists/pl.047294ae14a24e5993d1f7ab2b127188/curator",  "data": [   {    "id": "976439548",    "type": "apple-curators",    "href": "/v1/catalog/us/apple-curators/976439548"   }  ] } Using this ID, I can get more information like the editorial notes, kind, artwork, etc. If I use MusicKit to get details about the playlist: let id = MusicItemID("pl.047294ae14a24e5993d1f7ab2b127188") let request = MusicCatalogResourceRequest<Playlist>(matching: \.id, equalTo: id) let response = try await request.response() guard let playlist = response.items.first else { return } print(playlist.curatorName) It does not expose the Curator object but only the curatorName. How can I access the ID of the curator?
Replies
3
Boosts
0
Views
2k
Activity
Jun ’22
MusicKit Custom Data Request
Hi, I am trying to use MusicDataRequest from MusicKit to get the user's library artists (https://api.music.apple.com/v1/me/library/artists). This works well, until I am trying to use pagination with it. The data returned by this endpoint contains a "next" property, which reads /v1/me/library/artists?offset=25. Replacing the URL as such resulting in https://api.music.apple.com/v1/me/library/artists?offset=25 no longer works, as the request returns an error: MusicDataRequest.Error( status: 400, code: 40008, title: "Invalid Path Value", detailText: "Unknown library resource type 'artists?offset=25'", ... ) It seems like the request cannot handle query parameters and considers them as part of the request's path. Is there any way to use query parameters with MusicDataRequest? Thanks for any response.
Replies
3
Boosts
0
Views
1.7k
Activity
Jun ’22
Using MusicKit to retrieve playlists and contents of playlists
What is the best approach to retrieve playlists using MusicKit. I can't seem to guess from the docs how to use the API to accomplish this, as well as retrieving tracks from a playlist. I am in the process of migrating code from Apple Music API to MusicKit and I potentially could use MusicDataRequest to retrieve playlists using the Apple Music API endpoints, but I want to be sure there are no better alternatives. Sample code would definitely help.
Replies
6
Boosts
0
Views
4.1k
Activity
Jun ’22
How to decode the JSON response from MusicKit Search Suggestion
Hello everyone, I am trying to understand how to decode the JSON response returned by the suggestions/top results endpoint in MusicKit As you can see the response returns suggestions, which has two different types, Albums and Songs within the same 'suggestions' array. How can I decode the response even if there are different types using a single struct? { "results" : { "suggestions" : [ { "content" : { "attributes" : { "url" : "https:\/\/music.apple.com\/us\/artist\/megan-thee-stallion\/1258989914", "name" : "Megan Thee Stallion", "genreNames" : [ "Hip-Hop\/Rap" ] }, "id" : "1258989914", "relationships" : { "albums" : { "data" : [ { "href" : "\/v1\/catalog\/us\/albums\/1537889223", "type" : "albums", "id" : "1537889223" } ], "next" : "\/v1\/catalog\/us\/artists\/1258989914\/albums?offset=25", "href" : "\/v1\/catalog\/us\/artists\/1258989914\/albums" } }, "href" : "\/v1\/catalog\/us\/artists\/1258989914", "type" : "artists" }, "kind" : "topResults" }, { "content" : { "href" : "\/v1\/catalog\/us\/artists\/991187319", "attributes" : { "genreNames" : [ "Hip-Hop\/Rap" ], "url" : "https:\/\/music.apple.com\/us\/artist\/moneybagg-yo\/991187319", "name" : "Moneybagg Yo" }, "id" : "991187319", "type" : "artists", "relationships" : { "albums" : { "href" : "\/v1\/catalog\/us\/artists\/991187319\/albums", "data" : [ { "id" : "1550876571", "href" : "\/v1\/catalog\/us\/albums\/1550876571", "type" : "albums" } ], "next" : "\/v1\/catalog\/us\/artists\/991187319\/albums?offset=25" } } }, "kind" : "topResults" } ] } }
Replies
5
Boosts
0
Views
3.3k
Activity
Jun ’22
How to get resources for a Genre?
I am trying to display albums, playlists and artist for a Genre. Does anyone know how to do this or if this is not currently supported by the MusicKit and Apple Music API?
Replies
4
Boosts
0
Views
2.1k
Activity
Jun ’22
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
Replies
1
Boosts
0
Views
3.5k
Activity
May ’22
Using AVPlayer to play Apple Music MusicVideos
In my app I'm trying to play an Apple Music video using VideoPlayer(player: AVPlayer(url: video.url!)) where "video" is a MusicVideo instance but all I get is a blank player. video.title and video.artistName work fine I've tried using fileURLWithPath and string also, which work with hosted videos no problem (apologies for the poor use of terms, newbie)
Replies
2
Boosts
0
Views
1.2k
Activity
Apr ’22
Music preview with MusicKit
Hi, I apologize for asking so many questions. I don't know that I'll ever ship anything but I'm experimenting with an old fashioned radio station like we used to program in the old top forties days. I'd like to allow the music programmers to listen to sets that they're building by skimming through songs - does MusicKit or any part of the API allow us to access the Music preview for a given song? i.e. - I want users with a subscription to be able to hear the 30 s preview that you can find in Music. I may be requesting that a Song have a preview as one of its playing mode options. Thank you, Daniel
Replies
9
Boosts
0
Views
4.6k
Activity
Apr ’22
How to make a playlist public/create a public playlist?
Hey everyone, I am creating playlist via the MusicKit API and by default it creates the playlist in the users library and the isPublic attribute is set to false. Is there a way to make the playlist public at the time of creation? (Only way to change isPublic = true at this time seems to be through the Music app right now)
Replies
1
Boosts
0
Views
2.5k
Activity
Apr ’22
Get a Catalog Playlist's Relationship Directly by Name
Hi there! I am trying to map the Apple Music API endpoints to MusicKit. For example, I am looking at the catalog playlist endpoints. To get a catalog playlist by its identifier, it is: let request = MusicCatalogResourceRequest<Playlist>(matching: \.id, equalTo: "pl.f4d106fed2bd41149aaacabb233eb5eb") let response = try await request.response() print(response.items) For multiple identifiers, it is:   let request = MusicCatalogResourceRequest<Playlist>(matching: \.id, memberOf: ["pl.f4d106fed2bd41149aaacabb233eb5eb", "pl.4b364b8b182f4115acbf6deb83bd5222"]) let response = try await request.response() print(response.items) To get its relationship like more by curator and featured artists, I can set the properties: var request = MusicCatalogResourceRequest<Playlist>(matching: \.id, equalTo: "pl.f4d106fed2bd41149aaacabb233eb5eb") request.properties = [.featuredArtists, .moreByCurator, .tracks] let response = try await request.response() print(response.items) My question is, how can I map the endpoint Get a Catalog Playlist's Relationship Directly by Name" to MusicKit: https://api.music.apple.com/v1/catalog/{storefront}/playlists/{id}/{relationship} The possible value of the relationship can be curator, library, or tracks. Where can I set these relationship values in the MusicKit request? Thank you!
Replies
1
Boosts
0
Views
1.4k
Activity
Apr ’22
Audio trait property in MusicKit
Hi there! I went through the Apple Music API and stumbled upon Get a Catalog Song's Relationship Directly by Name, an endpoint to fetch a song's relationship by using its identifier. If you take a look at the example given on the page: https://api.music.apple.com/v1/catalog/us/songs/1572278914/albums And see the response, it has a property called audioTraits: “audioTraits”: [ “lossy-stereo”, “lossless”, “atmos”, “spatial” ] And another one hasTimeSyncedLyrics: “hasTimeSyncedLyrics”: true Although, I cannot find these two properties in MusicKit's Song. If I hit the API directly using a developer token generated, it does not have these properties as well. I know Apple cannot disclose if these properties will be available in the future or not, but curious nonetheless.
Replies
1
Boosts
0
Views
1.9k
Activity
Mar ’22
MusicKit and Export Compliance
Hi, I'm answering the questions on whether or not my app uses encryption. Do calls using MusicKit mean that I have to answer "Yes"? Do these calls qualify for the exemptions referred to in the App Store question: "Does your app qualify for any of the exemptions provided in Category 5, Part 2 of the U.S. Export Administration Regulations?"
Replies
1
Boosts
0
Views
1.5k
Activity
Feb ’22