Play/Pause Music from the Terminal

Toggle playback in the Music app with a one-line AppleScript.

macOSaudioosascriptplaybackLow risk
Run `osascript -e 'tell application "Music" to playpause'` to toggle play/pause.

01Command

Command
$ osascript -e 'tell application "Music" to playpause'

02What it does

playpause flips between playing and paused, so the same line works as a remote-control toggle — handy in shell scripts, SSH sessions, or when the media keys are being captured by another app. Other useful verbs are `play`, `pause`, `next track`, and `previous track`. The Music app launches in the background if it isn't already running.

03Risk

RiskLow risk
!Warning: This controls the Apple Music app only — Spotify and browser players need their own AppleScript or media-key commands.

04Undo

✓No undo needed — this command does not change persistent state.

05Sources

Last verified: 2026-09-18 · Category: Media

06Related solutions