next track and previous track
-
How to skip to the next track or go back to the previous track on MAC?
-
@Waldex-Santos, good question. I'll add these to the Mac examples.
This command presses the left arrow key which starts the music track over from the beginning, or goes to the previous track if it's already at the beginning:
osascript -e 'tell application "System Events" to key code 123'
This presses the right arrow key, which skips to the next track:
osascript -e 'tell application "System Events" to key code 124'
You can find codes for other keys here:
https://apple.stackexchange.com/questions/36943/how-do-i-automate-a-key-press-in-applescript -
@Russ said in next track and previous track:
osascript -e 'tell application "System Events" to key code 124'
Thanks, Russ
But I wanted a command that works in the background to advance the spotify track, for example, without having to have the program in the foreground -
@Waldex-Santos, I found the solution here.
osascript -e 'tell application "Spotify" to play' osascript -e 'tell application "Spotify" to pause' osascript -e 'tell application "Spotify" to next track' osascript -e 'tell application "Spotify" to previous track'
Thanks again for the question.
-
This post is deleted! -
@Russ It worked. Thank you very much
Two more questions:
1- As for the volume on spotify?
2- Do you have a command to open spotify and play a specific playlist, album or specific song (or singer)? -
@Waldex-Santos, this will play 80's love songs:
osascript -e 'tell application "Spotify" to play track "spotify:playlist:37i9dQZF1DXc3KygMa1OE7" '
You can get the "track" info from Share -> Copy Spotify URI
According to this file, there's also a playpause option but no way to set the volume in Spotify. You can set the Mac's general volume though of course.
- /Applications/Spotify.app/Contents/Resources/Spotify.sdef
-
@Russ do you know some examples to open a spotify playlist or the next song or so but for windows?
-
@Hector-M, this command works for me:
nircmd sendkeypress ctrl+right
I just tested it from my phone. You have to have the Spotify window in the foreground.