The audio section of the touch bar can automatically detect which app is playing audio, and adds media controls to play/pause, skip, and seek through any audio. As an example, this works for Quicktime, Spotify, and even YouTube audio from browsers like Google Chrome. How can I use AppleScript to mimic these functions? I want to get the name of the song, be able to play/pause, skip, and even seeking if that is possible.
I made a cli tool that lets you read properties from the private
Since it uses private APIs, it may break with future macOS updates but is currently working on Ventura 13.1.
The tool also supports commands like play/pause:
If you want to call this from AppleScript you can use the following syntax:
do shell script "<your command>"
This is a very useful tool and I have a recommendation on the best place to learn how to use AppleScript to interact with media.
This is 100% possible and you might even find the exact script you need, already written. Worst case, you can see the code and hopefully adapt one to your needs.