开发者

how to "reveal"/select a track using the ITunes API

开发者 https://www.devze.com 2022-12-19 20:16 出处:网络
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 li

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消