Post

Replies

Boosts

Views

Activity

Reply to Play songs from library
Thanks @Joekun!, I really like the direction this api is taking! I've updated my code. And it now kind of works. I can find the album and play a song. But playing the complete album doesn't work, on iOs 15 beta 5 and tvOS.     func searchLuwten () {         struct MyAlbums : Codable {             let results : Result         }                  struct Result : Codable {             let libraryAlbums : Albums             enum CodingKeys: String, CodingKey {                 case libraryAlbums = "library-albums"             }         }         struct Albums : Codable {             let href : String             let data : [Album]         }                  Task.detached {             let term = "LUWTEN"             var components = URLComponents()             components.scheme = "https"             components.host   = "api.music.apple.com"             components.path   = "/v1/me/library/search"             components.queryItems =  [                 URLQueryItem (name: "term", value: term),                 URLQueryItem (name: "types", value: "library-albums")             ]                          guard let url = components.url else {                 return             }                          let dataRequest = MusicDataRequest(urlRequest: URLRequest(url: url))             let dataResponse = try await dataRequest.response()                          let decoder = JSONDecoder()             let albumResponse = try decoder.decode (MyAlbums.self, from: dataResponse.data)             let player = ApplicationMusicPlayer.shared             let album = albumResponse.results.libraryAlbums.data[0]             let detailedAlbum = try await album.with([.artists, .tracks])                                                                             player.queue = [detailedAlbum.tracks![0]] // Playing one or more tracks works, but adding the complete album does not work //            player.queue = [detailedAlbum] // This doesn't work, // Error is MPMusicPlayerControllerErrorDomain Code=6             try? await player.play()                      }
Aug ’21