So far, I have red many conflicting answers about this.
In this SO thread, it is said to use:
let player = MPMusicPlayerController.systemMusicPlayer()
if let mediaItem = player.nowPlayingItem {
// ...
}
However, this only works with the iOS player. If the current song is being played by Spotify for example, mediaItem
will be nil
.
I understand that Apple's policy doesn't allow to access any other application's data. The only thing I am able to do right now is to know if a song is playing from another player with the help of AVAudioPlayer
's secondaryAudioShouldBeSilencedHint
and isOtherAudioPlaying
.
I want to know, however, if there is another way to access it, like using Spotify
framework? (I am absolutely non familiar with it, that's just making assumptions).
Thanks for your help.