title: Found an iTunes Controller API for Java, how can I play a specific song?
body: <pre><code>        //Using iTunes Controller
          iTunes itc = new iTunes();
          itc.playFile(filePath); // Takes type String
  </code></pre>
  
  <p>Seems like the right course of action.  However, I want the user to be able to specify simply the song title...</p>
  
  <p>I could use a prompt to get the Artist and Album to see what folders to browse to, since that's how iTunes stores its files ...(e.g.  C:\Users\username\Music\iTunes\iTunes Media\Artist\Album\song)</p>
  
  <p>Does anyone know a way I can just go straight to the specified song? I've been searching for a while.  </p>
  
  <p>Here are the docs for the API I'm using if that helps <a href="http://www.dot-totally.co.uk/software/itunescon/javadoc-0.2/index.html" rel="nofollow">http://www.dot-totally.co.uk/software/itunescon/javadoc-0.2/index.html</a></p>
  
  <p>UPDATE----------------------------------</p>
  
  <p>So I got up to....</p>
  
  <pre><code>//Using iTunes Controller -- Still doesn't work
  iTunes itc = new iTunes();
  ITSourceCollection sc = (ITSourceCollection) itc.getSources();
  ITSource source = sc.getItemByName(song);
  int trackID = source.getTrackID();
  // Now what to do with the track id? Look for getTrack by ID, then track.play();
  // Found that a TrackCollection can return a Track by ID.
  // Need to find out how to get the TrackCollection of the library
  </code></pre>
  
  <p>I'm stuck.... :(</p>
  
  <p>EDIT:</p>
  
  <p>Figured I could just manually create a track based on the info I can get from the sourcecollection.  Confused about the constructor though...</p>
  
  <p>ITTrack(com.jacob.com.Dispatch d) </p>
  
  <p>???? Can anyone clarify what the correct syntax would be to create an ITTrack object?
  here is the javadoc for it, I don't understand it.</p>
  
  <p><a href="http://www.dot-totally.co.uk/software/itunescon/javadoc-0.2/com/dt/iTunesController/ITTrack.html" rel="nofollow">http://www.dot-totally.co.uk/software/itunescon/javadoc-0.2/com/dt/iTunesController/ITTrack.html</a></p>
  
  <p>UPDATE--------------------------------------</p>
  
  <p>Ok. So I used the fetchDispatch() method to create an ITTrack class.
  <a href="http://www.dot-totally.co.uk/software/itunescon/javadoc-0.2/com/dt/iTunesController/ITObject.html#fetchDispatch()" rel="nofollow">http://www.dot-totally.co.uk/software/itunescon/javadoc-0.2/com/dt/iTunesController/ITObject.html#fetchDispatch()</a></p>
  
  <pre><code>//Using iTunes Controller -- work in progress
  iTunes itc = new iTunes();
  ITSourceCollection libsource = (ITSourceCollection) itc.getSources();
  ITSource trackToPlay = libsource.getItemByName(song);
  ITTrack track = new ITTrack(trackToPlay.fetchDispatch());
  track.play();
  </code></pre>
  
  <p>I'm now getting an exception:</p>
  
  <pre><code>Exception in thread "main" java.lang.NoSuchMethodError: com.jacob.com.Dispatch.call(Lcom/jacob/com/Dispatch;Ljava/lang/String;Ljava/lang/Object;)Lcom/jacob/com/Variant;
  at com.dt.iTunesController.ITSourceCollection.getItemByName(ITSourceCollection.java:49)
  at Build.Clapper3.process(-----.java:117)
  at Build.Clapper3.main(-----.java:232)
  </code></pre>
  
  <p>gahhh so close!  So I'm doing something wrong with my method of entry for the "name" of the item....but what?</p>
  
  <p>I figured maybe if i input:</p>
  
  <pre><code>System.out.println(libsource.toString());
  </code></pre>
  
  <p>to find the names of the sources....but I guess it has no toString() method?
  the output was:</p>
  
  <pre><code>com.dt.iTunesController.ITSourceCollection@118278a
  </code></pre>