r/applescript • u/kwxl • Nov 13 '20
Big Sur Broke my Script
If I play a song from my library to works, but if I play from Apple Music I get an error.
"Cant get name of current track"
Anybody else with this issue? Fix?
//Thanks
tell application "Music"
if player state is stopped then
set trackName to ""
set artistName to ""
set output to artistName & "" & trackName
else if player state is paused then
set trackName to name of current track
set artistName to artist of current track
set output to artistName & " - " & trackName
else if player state is playing then
set trackName to name of current track
set artistName to artist of current track
set output to artistName & " - " & trackName
else
set trackName to ""
set artistName to ""
set output to artistName & "" & trackName
end if
end tell
UPDATE
Big Sur 11.3 fixes the issue
2
u/[deleted] Nov 14 '20
Same problem ugh
2
u/sariduvar Nov 17 '20 edited Nov 17 '20
I have checked the syslog messages when I run my code that produces a similar error, and I can see that it is an assertion failure:
I could not yet find out how to mitigate this problem, but maybe it would help someone.
2
u/HououinKami Nov 29 '20
I found a imperfect method to get the information about Apple Music track, but you must put the Music in the dock and every time it gets the info, the right-click menu will popup and disappear quickly.
tell application "System Events"tell process "Dock"tell list 1tell UI element "Music"perform action "AXShowMenu"set songInfo to the name of every menu item of menu 1-- you can get title, artist, album, loved, disliked info in the list songInfoperform action "AXShowMenu"get songInfoend tellend tellend tellend tell2
u/pavethequad Dec 14 '20 edited Dec 25 '20
I have the exact same issue in Big Sur. I use AppleScript to retrieve track details in my macOS app (written primarily in Swift). When running on Catalina, the commands successfully pull song info (including album art) whether or not the track has been added to the library. Big Sur breaks this by not returning any data unless the track has been added, and I haven’t been able to find a reasonable workaround.
As I recall, this happened once before with a macOS upgrade and was eventually fixed in an update to Music. I hope we can count on a fix happening again.
Also, here’s a shameless plug for my app in the macOS App Store: Dock Party for Apple Music and Spotify
2
u/Shpigford Feb 10 '21
I'm on Big Sur 11.3 Beta and still having this issue. As others have noted, this error seems to only be thrown on songs that are NOT already saved to your Library.
2
u/Shpigford Feb 19 '21
Small update. As of Big Sur Beta 2 (20E5186d), I no longer get the error about being unable to get the track name for songs NOT in my library.
1
u/HououinKami Nov 13 '20
I just upgrade to Big Sur, and the same problem, and I find it works when the song from Apple Music have added to library
0
u/[deleted] Nov 14 '20
[deleted] — view deleted comment