如何通过命令行工具获取Mac上当前正在播放的歌曲?
我只能在Google上找到一些带有特定音乐应用程序(例如iTunes,Spotify等)的苹果本,以获取当前播放歌曲。
但是现在我正在使用不支持AppleScript控制的NetEase音乐,我想知道是否有任何通用方法可以通过Mac Media Center获取当前的歌曲信息?
AppleScript和其他命令行工具都可以。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我制作了一个 cli 工具,可让您从私有
MediaRemote
框架读取属性。https://github.com/kirtan-shah/nowplaying-cli
因为它使用私有API,它可能会随着未来的 macOS 更新而中断,但目前正在 Ventura 13.1 上运行。
这是一个检索歌曲名称的示例:

I made a cli tool that lets you read properties from the private
MediaRemote
framework.https://github.com/kirtan-shah/nowplaying-cli
Since it uses private APIs, it may break with future macOS updates but is currently working on Ventura 13.1.
Here is an example that will retrieve the song name:

下面的 AppleScript 代码使用 UI 脚本来检索当前播放的媒体。
This following AppleScript code uses UI scripting to retrieve the currently playing media.