确定第三方应用程序正在iPhone上播放的歌曲

问题描述:

我正在尝试确定当前在iPhone上播放的歌曲的标题.我知道我可以使用以下代码来查找本地Apple应用程序正在播放音乐时正在播放的音乐,但是如果从Spotify或其他音乐播放应用程序中播放歌曲,如何查找歌曲的标题?

I am trying to determine the title of the song currently being played on an iPhone. I know I can use the following code to find out what is playing if the native Apple app is playing the music but how do I find the title of a song if its being played from Spotify or some other music playing app?

MPMediaItem *nowPlayingItem = [[MPMusicPlayerController iPodMusicPlayer] nowPlayingItem];
NSString *itemTitle = [nowPlayingItem valueForProperty:MPMediaItemPropertyTitle];

如果在其他应用程序中播放歌曲,您将无法获得歌曲标题!

No you can't get title of song if its playing in some other app!

编辑1-

您不能这样做,因为Apple的政策非常严格,每个应用程序都在自己的小沙箱中运行,该沙箱无法访问任何其他应用程序数据.

You can't do that because Apple has a very strict policy that runs every app in its own little sandbox that cannot access any other applications data.

-谢谢Emil ...

-- Thanks Emil ...