How to detect an iTunes track change?

There are several ways to get an information window of the currently playing track in iTunes, using KM & AppleScript combined, like the one posted recently - Create an iTunes song info window with Custom HTML Prompt
I created another way of approaching that use case, I'll post it shortly - it has larger graphics & more information like composer, which is something you'd like for classical music. Here's a screenshot:


But what I'd like is a window to show itself for x seconds every time a new track starts, like what the brilliant YouControl:iTunes used to do - an application no longer supported unfortunately.
So is there a way, using KM or AppleScript or whatever else to detect a track change in iTunes?

Thanks & cheers --Mike

I imagine the only way would be to poll iTunes relatively frequently to detect the change.

It’s kinda strange that we couldn’t somehow “intercept” the notification sent to the Notification Manager… I’m afraid that polling frequently would either add extra load on the system or would not suffice if you don’t do it enough…

Apple are unlikely to allow applications to see notifications sent to be displayed to the user.

These kinds of things are always an issue when trying to do automation. We're at the mercy of what the vendor supplies. After that, creativity is our only answer.

I think you'll find that there won't be a noticeable impact on the system, unless you poll continuously without a pause of some kind.

I would think iTunes can tell you how much time is left in a track it is playing, so that could help you determine how long to pause before you need to poll again.

Of course, if you manually skip to a new track, you'll have to take that into account, so perhaps you want to make sure you poll at least every 5 seconds or whatever makes sense to you. Or else only change tracks using your own macros, which will of course know when the track changes.

2 Likes

If you’re going to poll frequently, you may be better off writing some sort of daemon script that runs continuously and checks iTunes periodically and then triggers a Keyboard Maestro macro when it detects a change.

That is actually very smart. I'll have a look at this. And see what kind of polling would be acceptable.

Thanks --Mike

1 Like