Question

I have created a small AppleScript that queries Music App if it is playing, and if it is then it queries and gets artist and song name. Now I want to query some more information.

Where can I find the documentation regarding the available commands and information that I can use from Music app? For example, I now use something like:

set a to "Now playing: " & artist of current track & " - " & name of current track

what else can I use except artist of current track or name of current track? Where can I find what other information can I query/use?

Was it helpful?

Solution

Where can I find what other information can I query/use?

Check out the Library in Script Editor.

Script Editor > Window > Library    ⇧⌘L

You can also query the properties of the current track to see what else is available specifically to it, e.g.:

tell application "Music" to get properties of current track

On my system at the moment, it returns:

{class:file track, id:181, index:8, name:"Brain Damage", persistent ID:"C2EE4E8E7AD4C9A6", database ID:157, date added:date "Saturday, November 21, 2020 at 3:59:39 AM", time:"3:50", duration:230.757995605469, artist:"Pink Floyd", album artist:"", composer:"Roger Waters", album:"Dark Side Of The Moon", genre:"Rock", bit rate:192, sample rate:44100, track count:9, track number:8, disc count:1, disc number:1, size:5595268, volume adjustment:0, year:1973, comment:"", EQ:"", kind:"AAC audio file", media kind:song, modification date:date "Tuesday, September 6, 2005 at 1:08:28 PM", enabled:true, start:0.0, finish:230.757995605469, played count:1, skipped count:0, compilation:false, rating:0, bpm:0, grouping:"", bookmarkable:false, bookmark:0.0, shufflable:true, lyrics:"", category:"", description:"", episode number:0, unplayed:true, sort name:"", sort album:"", sort artist:"", sort composer:"", sort album artist:"", loved:false, disliked:false, album loved:false, album disliked:false, cloud status:unknown, work:"", movement:"", movement number:0, movement count:0, location:alias "Macintosh HD:Users:me:Music:Music:Media.localized:Pink Floyd:Dark Side Of The Moon:08 Brain Damage.m4a"}

Also have a look at: About Scripting Terminology:

The terminology for an app is found in its scripting dictionary, an .sdef file stored in the app bundle. The dictionary describes the commands, classes, and properties an app supports. This information is used by the scripting components of the operating system, the app itself, and any other apps or scripts that interact with the app through scripting. It also serves as a reference, which you can consult in Script Editor for guidance as you write a script. See Figure 10-1.

Figure 10-1Example of a scripting dictionary in Script Editor

enter image description here

Licensed under: CC-BY-SA with attribution
Not affiliated with apple.stackexchange
scroll top