Jahphone
Jahphone

Reputation: 7

Query a user's "Now Playing" in iTunes?

I am trying to create an application similar to the last.fm scrobbler. but geared specifically to a certain artist. I'd like to be able to call the album the user is currently playing in tunes and based on the first 10 numbers of the album (should be a date i.e. "1999-05-10") queue up either a website or specific information regarding that date. If anyone can even begin to help me with this it would be greatly appreciated. I signed up with Apple's SDK but haven't been able to get a really clear answer on this.

I know it all starts with something like this:

var iTunesApp = WScript.CreateObject("iTunes.Application");
iTunes.App.CurrentTrack (   [out, retval] IITTrack **   iTrack   )  

but don't feel like I'm getting anywhere. Again any help would be greatly appreciated.

Upvotes: 0

Views: 151

Answers (1)

Helen
Helen

Reputation: 98022

To get the album containing the current track, use the CurrentTrack.Album property of the iTunes.Application object:

var iTunes = WScript.CreateObject("iTunes.Application")
var album = iTunes.CurrentTrack.Album;

var date = album.substr(0, 10);
...


Tip: A great way to learn the available properties and methods of the iTunes COM object is to use some ActiveX/COM/OLE object browser, e.g. Visual Studio's Object Browser, to explore the iTunes type library (contained in the iTunes.exe file).

Upvotes: 1

Related Questions