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

    next track and previous track

    Mac
    3
    9
    3.1k
    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.
    • Waldex SantosW
      Waldex Santos
      last edited by

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

      RussR 1 Reply Last reply Reply Quote 0
      • RussR
        Russ @Waldex Santos
        last edited by Russ

        @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

        Hector M.H 1 Reply Last reply Reply Quote 0
        • Waldex SantosW
          Waldex Santos
          last edited by Waldex Santos

          @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

          RussR 1 Reply Last reply Reply Quote 0
          • RussR
            Russ @Waldex Santos
            last edited by Russ

            @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

            Waldex SantosW 1 Reply Last reply Reply Quote 0
            • Waldex SantosW
              Waldex Santos
              last edited by

              This post is deleted!
              1 Reply Last reply Reply Quote 0
              • Waldex SantosW
                Waldex Santos @Russ
                last edited by

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

                RussR 1 Reply Last reply Reply Quote 0
                • RussR
                  Russ @Waldex Santos
                  last edited by Russ

                  @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
                  • Hector M.H
                    Hector M. @Russ
                    last edited by

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

                    RussR 1 Reply Last reply Reply Quote 0
                    • RussR
                      Russ @Hector M.
                      last edited by

                      @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