How can I make downloaded Apple Music songs fade out (volume decrease steadily over a few seconds)?
Recently I've been getting into trying to get Apple Music songs to play in my app. I've gotten them to play through the system/application music player of the MPMusicPlayerController. This is all good until I have to fade the music.
I've been able to replicate this fading stuff using an AVPlayer, since I have complete control over the volume of the music. The problem with AVPlayer, though, is that it needs a URL to a file of downloaded music to play it. Apple Music songs are by default locked and it's impossible to get their URLs. I can get the URLs of downloaded iCloud Music Library songs, and I've been able to play those and make them fade out all I want.
It seems the only way to play songs downloaded from Apple Music is through a MPMusicPlayerController (either the application player or system player). The problem with these is that neither of them have volume control and they rely on the system volume to determine how loud to play the music. Therefore, I can't fade the music out with them. (I did try some weird hack to change the system volume by making Apple's custom volume control slider and programmatically changing the values, but it was extremely finicky and I could never get it to fade properly)