Unable to read object properties with AppleScript: “Music got an error: Can’t get properties of current track.”
-
31-05-2021 - |
Question
I am trying to write an AppleScript that will tell me the current playing song, but I am unable to read properties from objects in AppleScript.
Executing a function on music works fine such as
tell application "Music" to play
tell application "Music" to pause
But trying to read a property such as the current track title does not. In fact, even trying to read the properties of the current track does not work. (Tested while a song was playing)
tell application "Music" to get properties of current track
returns error "Music got an error: Can’t get properties of current track." number -1728 from properties of current track
Per this question, the above script should work: AppleScript and Music
I did get this to work when I was trying before when I was looking at the permissions, but then it stopped working since then so it might have been working for another reason. I'm running the script in script editor, which does have accessibility access in my security & privacy settings.
Possibly related issue: Applescript - Getting Property of an Object Not Working