Me and my girl friend share a spotify account. As you probably know only one can listen at the same time. This results in endless "play-pause-fights". The problem is that I listen to spotify at work, so I don't have time to click play for more then about 15 minutes, so she wins.
Therefore I wanted to do as I always do when I am facing repetative tasks, make a script. I found a spotify module in powershell called PSSpotify. There I could call:
Invoke-Spotify -play
But this is actually -playpause, so in my loop:
while ( $true ){ sleep 1; invoke-spotify -play }
I paused my track every second, which was a bit anoying. So my question:
Can I run a command to check if spotify is playing?
Did you mean you want to check if the Spotify app process?
Get-Process -Name *spotify*
That will tell you if spotify process is running or not. I mean, if the process is running, it will return the details about that process.
So, you can do something like:
if (Get-Process -Name spotify) { #Do something }
Update: If you want to know if Spotify is playing or not, the answer is in the PSSpotify module:
Get-SpotifyStatus
This tells you if Spotify is currently playing a song
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With