How to detect a song playing by iPod

旧时模样 提交于 2019-12-08 03:16:41

问题


Is it possible programmatically find out a song details of iPod library if my app allows playing background iPod music? some like:

start "My app"
if (iPod music playing)
{
song.details == playing.music.details"
}

I don't even have no idea how to determinate if is any song is playing by iPod. Any idea?


回答1:


It kinda easy:

MPMusicPlayerController *musicPlayer = [MPMusicPlayerController iPodMusicPlayer]];

NSLog(@"Playing %@", [[musicPlayer nowPlayingItem] valueForProperty:MPMediaItemPropertyArtist]);



回答2:


See the Media Player Framework Reference:

"This framework...gives your application access to the iPod library."



来源:https://stackoverflow.com/questions/4138247/how-to-detect-a-song-playing-by-ipod

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