Get current track playing on control center iOS

后端 未结 1 402
太阳男子
太阳男子 2021-01-06 02:04

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

相关标签:
1条回答
  • 2021-01-06 02:35

    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.

    0 讨论(0)
提交回复
热议问题