Browse the docs

Music and player control

Controls Music, Spotify or QuickTime Player: play, pause, skip, volume, rating and the current track.

Control the music player: command

Keyboard Maestro: iTunesControl, QuickTimePlayerControl, QuickTimePlayerVolumeControl

Details #

Sends one command to a media player through AppleScript. app picks the player: music (the default, also accepts itunes), spotify, or quicktime. command says what to do. op is another spelling of command; command names ignore case.

The commands:

  • play, pause, playPause, stop, next, previous. On Spotify, stop pauses. On QuickTime, stop pauses and goes back to the start.

  • rewind and fastForward jump back or ahead by value seconds (10 if left out). Music and Spotify only.

  • playRandomTrack plays a random track from the library. playRandomPlaylistTrack plays a random track from the playlist name (from the whole library if name is empty). Music only, apart from the Spotify link form below.

  • playTrack plays the first library track called name. playPlaylist plays the playlist called name. Both need name. On Spotify, name must be a spotify: link, and playRandomPlaylistTrack takes one too.

  • volumeUp and volumeDown change the player's own volume by value points (10 if left out), held between 0 and 100.

  • setVolume sets the player's volume from 0 to 100. Needs value.

  • ratingUp and ratingDown change the current track's rating by one star (20 points). setRating takes 0 to 5 stars, or 0 to 100; a value of 5 or less is read as stars. Music only.

  • stepForward and stepBackward move QuickTime's movie by one frame.

  • currentTrack returns the current track as Name - Artist. Music and Spotify.

The output is whatever the player returns, which is only useful for currentTrack. If you give into, the same text is stored in that variable.

Parameters #

ParameterTypeRequiredValuesWhat it does
commandone ofYesplay pause playPause stop next previous rewind fastForward playRandomTrack playRandomPlaylistTrack playTrack playPlaylist volumeUp volumeDown setVolume ratingUp ratingDown setRating stepForward stepBackward currentTrackRequired. One of the commands above.
appone ofmusic spotify quicktimemusic (default), spotify or quicktime. Anything else fails.
intotextA variable that receives the text the player returned.
nametextA track or playlist name. Spotify needs a spotify: link here instead.
optextAnother spelling of command.
valueany valueA number: seconds for rewind and fastForward, points for volume commands, stars or points for ratings.

Every step also accepts label, onFailure, timeout and dryRunSafe.

Examples #

Show what is playing in Music (changes nothing)
Do
  1. Music: current track
  2. Show “Now playing: {{track}}”
Open in Switchboard to try it

Gotchas #

  • The first run asks for permission to control the player (System Settings > Privacy & Security > Automation). If you decline, the step fails with Switchboard Engine isn't allowed to control Music.

  • If the player is not installed or not running, the step fails with Music isn't available (not installed, or not running).

  • Asking a player for something it cannot do fails, for example Spotify can't do "ratingUp" (it has no ratings, random-track or step commands). Spotify plays by link: playTrack and playPlaylist need a name that starts with spotify:.

  • An unknown command fails and lists the valid ones.

  • This is the player's own volume. For the Mac's output volume use System volume.

  • In a dry run the step is simulated, so currentTrack gives no real answer.

See also #

System volume, Switch audio device, Show notification