I've created a button which takes a selected album's store id and puts it in a queue for the music player, but for some reason, it does not play and returns the following error:
Failed to prepareToPlay error: Error Domain=MPMusicPlayerControllerErrorDomain Code=6
Here is the code for the button (I put the player vars in there to be easier for here)
var storeIds: [String] = [ "ID" ]
Button(action: {
let player = MPMusicPlayerController.applicationQueuePlayer
let queue = MPMusicPlayerStoreQueueDescriptor(storeIDs: storeIds)
storeIds = ["\(album.id)".replacingOccurrences(of: "l.", with: "")]
print("ID: ", storeIds) // Example ID: ["Qn4Bnha"]
player.setQueue(with: storeIds)
player.play()
})
Also, I remove the "l." from the id because every album starts with that which is not needed.