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,
stoppauses. On QuickTime,stoppauses and goes back to the start.rewind and fastForward jump back or ahead by
valueseconds (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 ifnameis empty). Music only, apart from the Spotify link form below.playTrack plays the first library track called
name. playPlaylist plays the playlist calledname. Both needname. On Spotify,namemust be aspotify:link, andplayRandomPlaylistTracktakes one too.volumeUp and volumeDown change the player's own volume by
valuepoints (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 #
| Parameter | Type | Required | Values | What it does |
|---|---|---|---|---|
command | one of | Yes | play pause playPause stop next previous rewind fastForward playRandomTrack playRandomPlaylistTrack playTrack playPlaylist volumeUp volumeDown setVolume ratingUp ratingDown setRating stepForward stepBackward currentTrack | Required. One of the commands above. |
app | one of | music spotify quicktime | music (default), spotify or quicktime. Anything else fails. | |
into | text | A variable that receives the text the player returned. | ||
name | text | A track or playlist name. Spotify needs a spotify: link here instead. | ||
op | text | Another spelling of command. | ||
value | any value | A 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 #
- Music: current track
- Show “Now playing: {{track}}”
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:playTrackandplayPlaylistneed anamethat starts withspotify:.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
currentTrackgives no real answer.