iTunes Search Plug-in for Google Deskbar
So here’s a Google Deskbar plug-in that searches your local iTunes playlist using iTunes COM API and plays the tunes found.
using System;
using Google.Desktop;
using iTunesLib;
public class iTunesSearch : ICustomSearch {
public string Title() { return "iTunes"; }
public OutputType GetOutputType() { return OutputType.kDeskbar; }
public string Run(string query, OutputType browser_type) {
IiTunes iTunesApp = new iTunesAppClass();
IITLibraryPlaylist playlist = iTunesApp.LibraryPlaylist;
IITTrackCollection tracks = playlist.Search(query, ITPlaylistSearchField.ITPlaylistSearchFieldAll);
if (tracks.Count > 0) {
// IITTrack track = tracks.Item(1);
IITTrack track = tracks.get_ItemByPlayOrder(1);
track.Play();
return track.Name;
} else {
return "No tunes found for " + query;
}
}
}
You need to import TypeLibs from iTunes.exe manually and make a reference to the DLL file. It can be done as follows:
% tlbimp "c:\program files\iTunes\ITunes.exe" /out:iTunesWrapper.dll /namespace:iTunesLib
% csc /target:libarary /out:iTunes.dll /r:deskbarex.dll /r:iTunesWrapper.dll iTunes.cs