• Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Register
  • Login
TRIGGERcmd
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Register
  • Login

next track and previous track

Mac
3
9
3.2k
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • W
    Waldex Santos
    last edited by Sep 12, 2020, 11:35 PM

    How to skip to the next track or go back to the previous track on MAC?

    R 1 Reply Last reply Sep 13, 2020, 2:07 PM Reply Quote 0
    • R
      Russ @Waldex Santos
      last edited by Russ Sep 13, 2020, 2:08 PM Sep 13, 2020, 2:07 PM

      @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

      Russell VanderMey

      H 1 Reply Last reply Feb 13, 2023, 3:59 AM Reply Quote 0
      • W
        Waldex Santos
        last edited by Waldex Santos Sep 13, 2020, 2:57 PM Sep 13, 2020, 2:57 PM

        @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

        R 1 Reply Last reply Sep 13, 2020, 11:48 PM Reply Quote 0
        • R
          Russ @Waldex Santos
          last edited by Russ Sep 13, 2020, 11:49 PM Sep 13, 2020, 11:48 PM

          @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.

          Russell VanderMey

          W 1 Reply Last reply Sep 14, 2020, 1:39 PM Reply Quote 0
          • W
            Waldex Santos
            last edited by Sep 14, 2020, 1:19 PM

            This post is deleted!
            1 Reply Last reply Reply Quote 0
            • W
              Waldex Santos @Russ
              last edited by Sep 14, 2020, 1:39 PM

              @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)?

              R 1 Reply Last reply Sep 14, 2020, 9:34 PM Reply Quote 0
              • R
                Russ @Waldex Santos
                last edited by Russ Sep 15, 2020, 1:09 AM Sep 14, 2020, 9:34 PM

                @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

                Russell VanderMey

                1 Reply Last reply Reply Quote 0
                • H
                  Hector M. @Russ
                  last edited by Feb 13, 2023, 3:59 AM

                  @Russ do you know some examples to open a spotify playlist or the next song or so but for windows?

                  R 1 Reply Last reply Feb 13, 2023, 11:01 PM Reply Quote 0
                  • R
                    Russ @Hector M.
                    last edited by Feb 13, 2023, 11:01 PM

                    @Hector-M, this command works for me:

                    afa0d876-61ba-49e5-a1df-86ba8bb4a86f-image.png

                    nircmd sendkeypress ctrl+right
                    

                    I just tested it from my phone. You have to have the Spotify window in the foreground.

                    https://nircmd.nirsoft.net/sendkeypress.html

                    Russell VanderMey

                    1 Reply Last reply Reply Quote 0
                    • First post
                      Last post