0

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

10
  • 1
    I cannot reproduce your error in macOS Big Sur 11.1, running tell application "Music" to get properties of current track in Script Editor returns the properties of the currently playing track in Music. Note that the currently playing track is a file located on the local disk. Where is the file located of the currently playing track that you get the error for? Commented Feb 2, 2021 at 17:37
  • 1
    I wonder if this is another Applescript perms issue. Try adding do shell script "osascript -e 'tell application \"Music\" to activate'" to the top of your script, then run your saved version, not from Script Editor itself. It seems to work to ask for perms. (You can trash the line once it works)
    – Tetsujin
    Commented Feb 2, 2021 at 17:53
  • 1
    I think it might a issue in big sur, refer to developer.apple.com/forums/thread/669239 @user3439894 could you give more details? Commented Feb 3, 2021 at 1:10
  • 1
    @Fenjin_Wang, Between my first comment, which is self-explanatory, Brian's comment to me, and the info in the link of your comment, what additional details are you looking for? This is clearly an issue/bug with AppleScript and Music with a streaming song as the current track vs. on on the local disk under macOS Big Sur. Commented Feb 3, 2021 at 1:30
  • 1
    Brian, everything I've ever listen to on iTunes/Music are songs ripped from my CD's as I do not download music or stream music. I guess it's true, the devil is in the details! :) Commented Feb 3, 2021 at 1:36

1 Answer 1

1

I'll summarize the discussion here:

  1. current track for streaming songs is broken in big sur, refer here
  2. current track only works for local files, refer to @user3439894 and here

And I had verify that if you download the songs in Music and then play it, you can successfully get the info.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .