While playing a game, you may want to listen to your playlist rather than the in-game music to get the most out of your gaming experience. Using the Xbox Gamebar and its Spotify widget to control your music playback without ever leaving your game. To control Spotify while in a game you need to click on the Widgets menu, as shown by the red arrow, and then select the Spotify widget. Once you link your Spotify account, you will be able to control Spotify, pause and play music, and select songs directly from within the game.
Source: https://www.bleepingcomputer.com/how-to/microsoft/how-to-control-spotify-while-playing-a-game-in-windows-10/

