Chase Walden
Chase Walden

Reputation: 1302

Get info of currently playing song OSX

I am currently trying to write a music visualizer of sorts, but I am running into a small issue.

I am familiar with the scripting bridge and being able to get various information from iTunes regarding the current track but I wanted to add support for other media players such as Spotify.

Since the Pause/Play, Next track, and Previous track buttons on the built in keyboard automatically direct the corresponding commands to the last used media player, I was assuming that there is a single library that I can call against to get this information, regardless of which music player is playing music.

Upvotes: 1

Views: 1168

Answers (1)

user149341
user149341

Reputation:

Since the Pause/Play, Next track, and Previous track buttons on the built in keyboard automatically direct the corresponding commands to the last used media player, I was assuming that there is a single library that I can call against to get this information, regardless of which music player is playing music.

Unfortunately, this is a false assumption.

The media keys on the keyboard are weird. They are (unfortunately!) not part of any larger media API; the fact that they even work at all for programs other than iTunes has taken some significant effort by developers.

iTunes publishes some information on the current track through a distributed notification. You can also get the name of the current track through AppleScript. This isn't part of any larger standard, though; other audio player applications may or may not do anything similar.

Upvotes: 1

Related Questions