5

I'm trying to return the information of the current iTunes Track, which is playing on my computer.

I can get single informations like this:

tell application "iTunes" get name of current track end tell 

This returns Thunderstruck for example.

But is it possible that I can get more information of the current track so it returns something like this:

"AC/DC, Thunderstruck, Iron Man 2" 

Is this possible? Or do I have to create multiple scripts?

Thanks

2 Answers 2

11

To get name, artist and album

tell application "iTunes" get {name, artist, album} of current track end tell 

The result is a list


To get everything

tell application "iTunes" get properties of current track end tell 

The result is a record

Sign up to request clarification or add additional context in comments.

Comments

1

In case you are using JXA, then:

  • To get track properties as a JavaScript object:
// File: GetTrackInfo.jxa const appMusic = Application("com.apple.Music"); const currentTrack = appMusic.currentTrack(); const properties = currentTrack.properties() // Get track info as a JSON console.log(JSON.stringify(properties, null, 2)) // Get certain track info property. console.log(properties.name) 
  • To get single track property:
// File: GetTrackInfoAndCopyToClipboard.jxa const currentApp = Application.currentApplication(); currentApp.includeStandardAdditions = true; const appMusic = Application("com.apple.Music"); const currentTrack = appMusic.currentTrack(); const result = `${currentTrack.artist()} - ${currentTrack.name()} @ ${currentTrack.album()}`; console.log(`Result: ${result}`); // Bonus, copying track into into Clipboard and sending notification. currentApp.setTheClipboardTo(result); currentApp.displayNotification(result); 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.