Since the latest updates of macOS, probably 14.1, I have not been able to play media using SystemMusicPlayer.shared or MPMusicPlayerController.systemMusicPlayer. ApplicationMusicPlayer still works.
This is the error code I am encountering:
systemMusicPlayer _establishConnectionIfNeeded failed [application failed to launch]
Failed to prepareToPlay with error: Error Domain=MPMusicPlayerControllerErrorDomain Code=10 "Failed to obtain remoteObject [nil server]" UserInfo={NSDebugDescription=Failed to obtain remoteObject [nil server]}
Here is a small example to reproduce the bug.
MPMusicPlayerController.systemMusicPlayer.setQueue(with: ["1445887715"])
MPMusicPlayerController.systemMusicPlayer.prepareToPlay()
Or:
extension PlayableMusicItem {
// Not working
func playWithSystemPlayer() {
Task {
SystemMusicPlayer.shared.queue = [self]
try await SystemMusicPlayer.shared.play()
}
}
// Working
func playWithApplicationPlayer() {
Task {
ApplicationMusicPlayer.shared.queue = [self]
try await ApplicationMusicPlayer.shared.play()
}
}
}