Note that there are some explanatory texts on larger screens.

plurals
  1. POConverting Java code thats calls iTunes DLLs from using Com4j to Jacob
    primarykey
    data
    text
    <p>I currently use Com4j to talk to iTunes from my Java app, unfortunately it does not work with 64bit Java and looks like it never will, so Im trying to use an alternative called Jacob instead.</p> <p>Both libraries provide a tool to generate Java classes from a DLL, and the resultant classes are very similar and its been straightforward to change most of the code but Im failing on how to find subtypes </p> <pre><code>IITPlaylist object = itunes.createFolder(TextLabel.SAVE_ITUNES_PLAYLIST_FOLDER.getMsg()); IITUserPlaylist playlistFolder = object.queryInterface(IITUserPlaylist.class); </code></pre> <p>Both libraries have created IITPlaylist and IITUSerPlaylist classes but only com4j provides the queryInterface class, and no IITUserPlaylist is not actually a subclass of IITPlaylist. </p> <p>Also com4j provides an is method, but jacob does not</p> <pre><code>if (next.is(IITFileOrCDTrack.class)) </code></pre> <p>Anyone know how to resolve these issues ?</p> <p>EDIT: Made some progress but still not got it working, there is a QueryInterface method that takes the guid of the class (include the curly brackets) , I found the guid by looking at the jacobgenlog.txt file which is created when you run jacobgen on the iTunes executable</p> <p>This then returns another Dispatch object that is meant to relate to the subclass, however the simple cast Ive done is invalid, whats the mising step ?</p> <pre><code> private static final String USER_PLAYLIST_GUID = "{0A504DED-A0B5-465A-8A94-50E20D7DF692}"; IITPlaylist object = itunes.createFolder(TextLabel.SAVE_ITUNES_PLAYLIST_FOLDER.getMsg()); IITUserPlaylist playlistFolder = (IITUserPlaylist)object.QueryInterface(USER_PLAYLIST_GUID); </code></pre> <p>The is() functionality is replaced by checking the kind</p> <pre><code>IITTrack next = tracks.getItem(i); if(next.getKind().equals(ITTrackKind.ITTrackKindFile)) </code></pre> <p>A spanner in the works is that jacobgen getKind() methods are invalid Java because they try to return a new interface, and of course you cannot instantiate an interface, so I had to modify them as follows</p> <p>ITPlayListKind goes from </p> <pre><code>public interface ITPlaylistKind extends __MIDL___MIDL_itf_iTunesCOMInterface_0001_0081_0001 { } </code></pre> <p>to </p> <pre><code>public enum ITPlaylistKind { ITPlaylistKindUnknown, ITPlaylistKindLibrary, ITPlaylistKindUser, ITPlaylistKindCD, ITPlaylistKindDevice, ITPlaylistKindRadioTuner; } </code></pre> <p>Within IITUserPlaylist</p> <pre><code>public ITPlaylistKind getKind() { return new ITPlaylistKind(Dispatch.get(this, "Kind").toDispatch()); } </code></pre> <p>to </p> <pre><code>public ITPlaylistKind getKind() { return ITPlaylistKind.values()[Dispatch.get(this, "Kind").getInt()]; } </code></pre> <p>this wasnt an original idea by me, I got the idea from <a href="http://dot-totally.co.uk/software/itunescon/" rel="nofollow">http://dot-totally.co.uk/software/itunescon/</a> which appears to be a modified version of the iTunes classes created by jacobgen, I didnt find it added that much and decided to stick with the jacobgen generated classes.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload