Hello,
I was trying to use the new ApplicationMusicPlayerController with an album from the music library. In my test code I am searching for the artist "LUWTEN" in my personal library. In my personal library there are two albums that will be found.
When I try to play the first album I will get the error MSVEntitlementUtilities - Process .. PID[648] - Group: com.apple.private.tcc.allow - Entitlement: kTCCServiceMediaLibrary - Entitled: NO - Error: (null)
.
Is there a way to play library music with the new ApplicationMusicPlayerController?
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 : [LibraryAlbum]
}
struct LibraryAlbum : Codable, PlayableMusicItem {
let id : MusicItemID
let attributes : Attributes
var playParameters: PlayParameters? {
attributes.playParams
}
}
struct Attributes : Codable {
let name : String
let playParams : PlayParameters
}
detach {
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
player.setQueue (with: albumResponse.results.libraryAlbums.data[0])
player.play()
}
}
Hello @dongelen,
You're on the right track here.
The log you pasted is not an actual error. That's a red-herring, which we're working on removing to reduce confusion.
I encourage you to try this again with the next seed of iOS 15; we've made a number of changes meant to enable this kind of usage.
Best regards.