Is it Possible to Add a Pause in Playback in Music.app?

I need to apply some pauses between a Music app playlist. I have a VERY clunky method right now - I literally drag in an audio file of silence that is set to the right amount, but that's a total pain.

Is there any way that I can automate this with KM and Music app? I did wonder if I could have something watch a timer, or something and when it sees 0:00 to press pause button, wait, then unpause. That also seems less than ideal.

Any thoughts on how I might achieve this in any elegant way would be appreciated!

I won't pretend it's elegant, but you could try this in an "Execute AppleScript" action. The playlist you want to use should be open in the main Music window when you run it. It'll grab the playlist's track list then play them one by one, with a 60 second delay between each.

I'm least happy about the "delay while a tack is playing" loop, but couldn't think of another way of pausing the script until the current track finished :frowning:

tell application "Music"
    set trackList to every track of (view of browser window 1)
    repeat with eachItem in trackList
        play eachItem with once
        repeat while player state is playing
            delay 1
        end repeat
        delay 60
    end repeat
end tell
2 Likes

Thanks for posting this. I finally gave it a try tonight but it did not appear to do anything. What I did was:

  • Pasted this in a Execute Apple Script block
  • Triggered it with a hot key
  • First time I saw a prompt about allowing KM access (I did not screenshot it, believe it was permission for automation).
  • Pressed OK

Nothing happened, unfortunately.

  • I had the playlist window open and had closed the main Music app window
  • The playlist was not playing yet

Any idea what I might have missed? Anything I can do to diagnose why it's not working?

I really appreciate you posting the script, hopefully it's some small detail I may have missed.

Happy to do a screencast to demo what is (or isn't happening) if that helps?

Best guess is that I said:

The playlist you want to use should be open in the main Music window when you run it.

...but you said:

I had the playlist window open and had closed the main Music app window

1 Like

OK, sorry I misread that entirely then. I had it in my mind that it should be a playlist window. OK. Apologies for that! Will try again.

OK, so it's not behaving still.

With the playlist I want selected and visible in the main window (not a new window), when I run the shell script, the playlist begins playing but when the first track ends:

  • There is no pause between tracks and (weirdly)
  • It jumps several tracks down in the playlist, not to the next track. (Went from track 1 to Track 5)

Any idea what might be happening there?

Music has been... patchy... in the implementation of its own AppleScript dictionary. What OS and Music versions are you using?

As to jumping -- I don't know if the listing will honour your playlist sort order, be based on original import time, playlist addition time, or something else. Again, let us know what version you are on and I'm sure someone will be able to test.

I pretty much keep up-to-date (apart from betas), so we have:

Music
Version 1.2.5.7

macOS Monterey
Version 12.6

I'll try to work out if there is a pattern. I would need it to honour the playlist order as it is shown, otherwise it won't be something that I can use. I wonder if there is a way I could force the play order.

Anyway, thanks for any ideas you might have on this.

Not sure what's going on -- my test machine is running the same versions as you and the script works fine, even honouring track order within the playlist. One obvious difference is that I don't have KM installed -- I can't see why it would make a difference, but try running the AppleScript in Script Editor instead and see what happens.

I did give this a go again recently, and it did appear to run more smoothly when I ran from Script Editor. Peculiar, really. I will do some more testing to see if I can work out a pattern on where it does not quite work.