Get current track playing on control center iOS

做~自己de王妃 提交于 2019-11-30 18:04:00

问题


I'm looking to get the current track playing on iOS whatever the app which is playing the track. I mean, for example, if I use SoundCloud or Spotify on my phone, the player on control center is the same, so I think it's possible to get the current track name.

However I don't know how to do this, maybe someone could help me ?


回答1:


Frustratingly you can only get the details of the songs playing on the Music (iPod) app:

// Print the title of the currently playing song.
NSLog(@"%@", [[[MPMusicPlayerController iPodMusicPlayer] nowPlayingItem] valueForProperty:MPMediaItemPropertyTitle]);

To get the details of songs from other apps you should be able to call:

[[MPNowPlayingInfoCenter defaultCenter] nowPlayingInfo]

but it always returns nil.



来源:https://stackoverflow.com/questions/23515633/get-current-track-playing-on-control-center-ios

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!