Individual app volume on Mac · Volume shortcuts
You press play expecting Spotify, and a YouTube tab you forgot about starts instead. Here's why, and how to fix it.
Short answer: macOS sends the media keys to the app that most recently became the “now playing” source. That isn't always the app in front, or the one you want. There's no setting to change it.
The play/pause, next and previous keys aren't tied to any app. macOS picks where each press goes, and the rule is roughly: whatever played audio last.
That works when only one thing is playing. But most Macs have several things that can play: a video in a background tab, a podcast you paused an hour ago, an autoplaying clip on a page you scrolled past. Any of them can take the keys, and you won't be told.
Browsers make this harder to track, because each page registers on its own. “Safari has the keys” really means one tab in one window has them, and you may not know which.
If nothing is registered, the play key opens Apple Music. That's why pressing play right after startup often opens a music library you didn't ask for.
Try these first. For some people they're enough.
Close the tab or quit the app, and the keys go back to whatever played before it. This works, but you have to do it every time.
The hard part is finding the culprit. Chrome and other Chromium browsers show a speaker icon on tabs that are playing. In Safari, click the speaker icon in the address bar to see which tabs are making sound.
Chromium browsers have a hidden setting for this. Open chrome://flags/#hardware-media-key-handling, set it to Disabled and relaunch. The browser then ignores the media keys, so they go to your music app.
It's all or nothing: the keys won't pause YouTube in that browser anymore either. Safari has no such setting.
In System Settings → Keyboard, turn on “Use F1, F2, etc. keys as standard function keys.” The top row then sends F-keys unless you hold fn. This doesn't change where media keys go, only how you press them. It helps if your problem is mostly accidental presses.
macOS has no setting that says “send the media keys to this app.” It isn't in Keyboard, Sound or Shortcuts. To choose the app, you need software that catches the keys before macOS routes them.
Beamhook does this. It's a small open-source menu-bar app. Pick an app, and play/pause, next and previous go there until you pick another. Background tabs, Apple Music and the app in front can't take them.
Beamhook catches the keys before macOS routes them, so “last player wins” never applies. In a browser you hook one tab, not the whole browser. Beamhook can take the volume keys too, and ⌘ + volume still changes system volume.
Built-in support: Spotify, Apple Music, Apple TV, VLC, VOX, QuickTime Player, Downcast, IINA, Amazon Music, Plexamp and Deezer, plus Safari, Chrome, Brave, Arc and Vivaldi. You can add other apps with AppleScript. Needs macOS 14 or later.
Beamhook also has per-app volume and mute, including for apps without AppleScript support (macOS 14.2 or later).
Beamhook is GPL-3.0. Building it yourself is free and takes one command. The €5 version is signed, notarized and ready to run, and supports development.