【问题标题】:How to get current playing song on mac by command line tools?如何通过命令行工具在 mac 上获取当前正在播放的歌曲?
【发布时间】:2023-02-07 04:43:06
【问题描述】:

我只能在谷歌上找到一些带有特定音乐应用程序(如 itunes、spotify 等)的 applescripts 来获取当前播放的歌曲。

但是现在我用的是不支持applescript控制的网易音乐,请问有没有什么通用的方法可以通过mac media center获取当前播放的歌曲信息?

Applescript 和其他命令行工具都可以。

【问题讨论】:

    标签: macos applescript


    【解决方案1】:

    这以下AppleScript代码使用 UI 脚本来检索当前播放的媒体。

    tell application "System Events" to tell process "Control Center"
        click menu bar item "Control Center" of menu bar 1
        set currentlyPlaying to value of static text 3 of window "Control Center"
        key code 53 -- press 'esc' key
    end tell
    
    activate
    display dialog currentlyPlaying with title "Currently Playing" buttons ¬
        {"OK"} default button 1 giving up after 3
    

    【讨论】:

      【解决方案2】:

      我制作了一个适用于 macOS Ventura 的工具:

      https://github.com/kirtan-shah/nowplaying-cli

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2017-07-25
        • 2011-04-10
        • 2020-10-14
        • 2015-05-17
        • 1970-01-01
        • 2012-08-10
        • 2021-05-25
        相关资源
        最近更新 更多