KeyRoutines
Gaming setupWorks on Free

How to pause music when a game starts and resume it after

Use KeyRoutines' Game started and Game stopped triggers with an If on Started by trigger. On start, an If with Media is playing pauses your player with Media control and Remember notes that the routine paused it; on stop, Remembered value is checks that note before Media control plays again.

Steps

  1. 1

    Add both game triggers

    Add Game started and Game stopped, with the game left empty for any game or set to one title.

  2. 2

    Branch on start or stop

    Add an If with Started by trigger set to Game started.

  3. 3

    Pause only what's playing

    In the If branch, add an If with Media is playing for Spotify; inside it, Media control set to pause and Remember with paused_for_game set to on.

  4. 4

    Resume only what you paused

    In the Else branch, add an If with Remembered value is paused_for_game on; inside it, Media control set to play and Remember paused_for_game off.

Tips

  • Media control talks to Windows' media controls, not the keyboard, so it works the same while a game is in front.
  • Name the player in Media control so a browser tab doesn't get the command instead.

Questions

Why remember anything?
So the routine doesn't start music you'd already paused yourself before playing.
Does it work with YouTube in a browser?
Yes, if the browser shows the video in Windows' media controls; most modern browsers do.

Blocks this routine uses

Trigger · GamesFree

Game started

Game started fires when any game in your launchers, or one game you pick, starts running. It is how gaming setups begin: switching to the headset, raising the refresh rate and pausing animated wallpapers as the game loads.

Trigger · GamesFree

Game stopped

Game stopped fires when a game you pick, or any game in your launchers, has fully closed. It is the other half of a gaming setup, undoing what Game started changed.

Condition · Flow and routinesFree

Started by trigger

Started by trigger checks which of a routine's own triggers began this run. That lets one routine react a little differently to a hotkey, a schedule or an app opening without keeping separate copies.

Condition · MediaFree

Media is playing

Media is playing is true while a player is actively playing. Check any player or one in particular, such as Spotify, so a routine can pause music only when there is music to pause.

Step · MediaFree

Media control

Media control sends play, pause, next, previous or stop to whatever is playing, or to a player you name. People use it to pause music for calls, resume it after games, and give keyboards without media keys a set of their own.

Step · Flow and routinesFree

Remember

Remember keeps a value safe after the routine ends, even across restarts of KeyRoutines and the PC. Use it for things like the last volume you set, a folder you picked, or whether you're away.

Condition · Flow and routinesFree

Remembered value is

Remembered value is reads a value saved by Remember or Toggle and answers a simple question about it. It's how a single hotkey knows whether to switch something on or put it back.

More how-to guides

Build this routine in KeyRoutines

Free from the Microsoft Store for Windows 11 and 10. Pro is a one-time upgrade.