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
Add both game triggers
Add Game started and Game stopped, with the game left empty for any game or set to one title.
- 2
Branch on start or stop
Add an If with Started by trigger set to Game started.
- 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
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.