是否可以通过 AirPlay(iOS、Swift)获取有关当前播放轨道的数据?
我的应用程序没有任何播放器,但它与可以播放音乐的蓝牙设备通信。我可以像这样获取有关当前音轨的信息:
let systemPlayer = MPMusicPlayerController.systemMusicPlayer
let nowPlayingInfo = systemPlayer.nowPlayingItem
然后只需获取如下数据:
print("title: \(nowPlayingInfo?.title)")
print("album title: \(nowPlayingInfo?.albumTitle)")
print("album artist: \(nowPlayingInfo?.albumArtist)")
print(" artist: \(nowPlayingInfo?.artist)")
但是,只有当 iTunes 正在播放某些内容(本地内容)时,我才能获取音频信息。当我通过 AirPlay 播放某些内容(例如使用 Spotify)时,我得到的只是 nil
。
如何像 iOS 在控制中心中获取每个场景的数据?:
查看音频信息
最佳答案
由于 Spotify 有自己的沙盒播放器,因此您将无法访问其信息。
但是,您可以使用 Spotify SDK获取有关当前播放轨道的信息,如果您设置和 register对于您的 Spotify 应用程序(在您的帐户仪表板上)。
查看此other SO post了解更多信息。
关于ios - MPMusicPlayerController.systemMusicPlayer 和 AirPlay 的播放信息?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51436467/