I have a problem with the music player, most songs give Error
Domain Error = MPErrorDomain Code = 4
The testing device has a subscription to Apple music, and the tracks give an error in the application, which they work perfectly in the Apple music application!
Here is the code:
let applicationMusicPlayer = MPMusicPlayerController.systemMusicPlayer()
applicationMusicPlayer.setQueueWithStoreIDs([ID])
if #available(iOS 10.1, *)
{
applicationMusicPlayer.prepareToPlay { (error) in
if (error != nil)
{
print("[MUSIC PLAYER] Error preparing : \(String(describing: error))")
return
}else
{
self.start_timer();
self.applicationMusicPlayer.play()
}
}
}else
{
self.applicationMusicPlayer.play()
}
}
But what I tried when the track gives this error, I went to the Apple music player and played from there, worked there, then I went back to my application and played it from my application, and it worked fine, so I need to go to Apple music app to play non-playing tracks in my app to make them work in my app! It is so strange that you think why?
PS: the testing device has a subscription to Apple music