8.3 C
New York
Monday, March 31, 2025

itunes – AppleScript (Music.app) error: Cannot get length of present observe


I’ve a easy AppleScript for beginning a random video on a random place in Music.app as Automator utility and as a startup login merchandise. Within the half of circumstances I get an error:

The motion “Run AppleScript” encountered an error: “Music acquired an error: Cannot get length of present observe.”

If I run it within the Script Editor it executes accurately.

I attempted so as to add “delay 5” earlier than the road “set Y to length of present observe” nevertheless it did not assist. Additionally tried so as to add “if” situation to give up Music.app whether it is working earlier than beginning the script, nevertheless it additionally did not change something.

enter image description here

inform utility "Music"
    run
    set tune repeat to all
    set shuffle enabled to true
    play playlist "Music Movies"
    delay 1
    set Y to length of present observe
    set X to random quantity from 0 to Y
    set participant place to X
    activate
finish inform

The error usually seems on the subsequent day if system was shutdown with the script:

inform utility "Finder" to close down

I assume that is in some way associated to the working state of Music.app on the second of shutting down the system, since after system startup all apps return to the identical state they have been earlier than shutting down, e.g. if I shut all my apps and restart the system utilizing Apple brand > Restart the script might be executed accurately and I will not see any errors on the display screen.

macOS Ventura 13.4

Thanks quite a bit

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles