在控制中心iOS上播放当前曲目 [英] Get current track playing on control center iOS

查看:277
本文介绍了在控制中心iOS上播放当前曲目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望在iOS上播放当前曲目,无论播放曲目的应用是什么。我的意思是,例如,如果我在手机上使用SoundCloud或Spotify,控制中心的播放器是相同的,所以我认为可以获得当前的曲目名称。

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 ?

谢谢

推荐答案

您只能获取在音乐(iPod)应用上播放的歌曲的详细信息:

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]

但它总是返回 nil

这篇关于在控制中心iOS上播放当前曲目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆