Use AppleScript to find the currently playing song (and other metadata) 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.
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.

https://dougscripts.com/itunes/index.php

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.