ios - MPMusicPlayerController.systemMusicPlayer 和 AirPlay 的播放信息?

标签 ios swift airplay

是否可以通过 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 在控制中心中获取每个场景的数据?:

查看音频信息

enter image description here

最佳答案

由于 Spotify 有自己的沙盒播放器,因此您将无法访问其信息。

但是,您可以使用 Spotify SDK获取有关当前播放轨道的信息,如果您设置和 register对于您的 Spotify 应用程序(在您的帐户仪表板上)。

查看此other SO post了解更多信息。

关于ios - MPMusicPlayerController.systemMusicPlayer 和 AirPlay 的播放信息?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51436467/

相关文章:

ios - 适用于越狱iOS设备的应用程序: Consistent background operation

ios - 指针缺少可空性类型说明符

ios - iOS/Objective-C 中的 TCP 客户端 - 检查开放端口

ios - swift 3 : How do you wrap content in a tableviewcell with multiple labels?

ios - 尽管设置了委托(delegate),UIScrollView 仍不滚动

swift - 带有约束的 UIView 动画在 Swift 中不起作用

ios - 在我的自定义按钮中打开 Airplay 弹出窗口

ios - 从自定义 UIButton 呈现 AirPlay 路由选择器

ios - 如何删除或替换字符串中的所有标点符号?

ios - 计数函数在 Swift 2 中不起作用