I am usin开发者_StackOverflow社区g the iTunes SDK/API through C#. I am trying to get iTunes to select a particular track in the music library list (i.e., highlight one particular line and only that line). I've been trying to do this with the Reveal() method:
iTunesApp app = new iTunesAppClass();
IITTrackCollection tracks = app.LibraryPlaylist.Tracks;
IITTrack track = tracks.get_ItemByPlayOrder( 50 );
IITFileOrCDTrack fot = t as IITFileOrCDTrack;
fot.Reveal();
But that Reveal() call seems to have no effect. I thought it would (a) switch to the music library screen in iTunes if iTunes was at a different screen (such as an album detail screen in the iTunes Store), (b) scroll the music track list display to bring the given item into view, and (c) highlight the given track line in the list.
Reveal() seems to do none of these. Any ideas on how I can make (a), (b), (c) happen?
I figured out how to make it work: You have to choose the track inside a "user playlist"!
If you choose a file track without specifying a playlist (this applies to using AppleScript on OSX to script iTunes), then the track is chosen from the "library playlist", which has no prepresentation in the UI, and thus can't be revealed.
Hence, if you make sure to get the item from a user playlist, e.g. the one whose "special kind" is "Music", then you're good.
精彩评论