Play/Pause option for iTunes instead of global media for TouchBar I have always liked my play/pause button to always affect my iTunes music and never any other application.

Since before macOS High Sierra, the media keys on the function bar always used to control iTunes. This was great as it allowed me to have full control over my music. that is, play music; find a YouTube video, pause music, start YouTube video. That YouTube video would then end then I would be able to play my music again.

Now since High Sierra, that doesn't happen. If I have a YouTube video up, it controls that instead of my music. This means that I have to open up iTunes, then click the play button and go back to Safari. I fixed this by using BetterTouchTool to reprogram the function buttons to bring back the pre High Sierra functionality.

Today, with the TouchBar, I am back with the same issue. Yes, I can use BetterTouchTool but now that requires two clicks. One to activate the BTT controller strips and another to press the play/pause button.

Is it posible to have a global button in the TouchBar controls strip that controls iTunes only?
I am 5 reputation short of being able to make this a comment, but I think it's enough of a solution that I can post it as an answer.

I do not have better touch tool or a menu bar (I do have keyboard maestro and I know you could probably do it using that).

However, what you can do is either script the menu item or send a keystroke to iTunes using applescript. You can then run it out of automator (and assign it a keyboard shortcut) or BTT or somehow just activate it using your touch bar.

According to this reddit post (https://www.reddit.com/r/apple/comments/8okzvg/macos_mojava_supports_automator_workflows_on_the/) mojava will add automators to the touch bar.



Either way, here's a script: 

tell application "System Events"
    tell application "iTunes" to activate
    key code 49
    set visible of process "iTunes" to false
end tell


It's not perfect, but it gets the job done.