Hi there, I am seeing an error when attempting to prepareToPlay
on iOS 15 Beta 5. I'm using SystemMusicPlayer's new .queue
property directly as setQueue
was deprecated. Are there other steps I should be doing to ensure that this method succeeds?
Code:
private func playAppleMusic(songs : [Song]) {
Task.init {
do {
print("0")
try await SystemMusicPlayer.shared.queue.insert(songs, position: .tail)
if (!SystemMusicPlayer.shared.isPreparedToPlay) {
print("1")
try await SystemMusicPlayer.shared.prepareToPlay()
}
print("2")
try await SystemMusicPlayer.shared.play()
} catch let error {
print("playAppleMusic error: \(error.localizedDescription)")
}
}
}
Result:
0
1
playAppleMusic error: The operation couldn’t be completed. (MPMusicPlayerControllerErrorDomain error 1.)