Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4076694
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T17:27:28+00:00 2026-05-20T17:27:28+00:00

I currently use Com4j to talk to iTunes from my Java app, unfortunately it

  • 0

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.

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

IITPlaylist object = itunes.createFolder(TextLabel.SAVE_ITUNES_PLAYLIST_FOLDER.getMsg());
IITUserPlaylist playlistFolder = object.queryInterface(IITUserPlaylist.class);

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.

Also com4j provides an is method, but jacob does not

if (next.is(IITFileOrCDTrack.class))

Anyone know how to resolve these issues ?

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

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 ?

 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);

The is() functionality is replaced by checking the kind

IITTrack next = tracks.getItem(i);
if(next.getKind().equals(ITTrackKind.ITTrackKindFile))

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

ITPlayListKind goes from

public interface ITPlaylistKind extends __MIDL___MIDL_itf_iTunesCOMInterface_0001_0081_0001 {

}

to

public enum ITPlaylistKind {
    ITPlaylistKindUnknown,
    ITPlaylistKindLibrary,
    ITPlaylistKindUser,
    ITPlaylistKindCD,
    ITPlaylistKindDevice,
    ITPlaylistKindRadioTuner;
}

Within IITUserPlaylist

public ITPlaylistKind getKind() {
        return new ITPlaylistKind(Dispatch.get(this, "Kind").toDispatch());
    }

to

public ITPlaylistKind getKind() {
        return  ITPlaylistKind.values()[Dispatch.get(this, "Kind").getInt()];
    }

this wasnt an original idea by me, I got the idea from http://dot-totally.co.uk/software/itunescon/ 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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T17:27:29+00:00Added an answer on May 20, 2026 at 5:27 pm

    As soon as I set a bounty I work out the answer for myself.

    Simply just use the constructor

    IITPlaylist object = itunes.createFolder
            (TextLabel.SAVE_ITUNES_PLAYLIST_FOLDER.getMsg());
    IITUserPlaylist playlistFolder = new IITUserPlayList(object);
    

    The QueryInterface and GUID sctrings re not required.

    I was also having a problem working out how to add a track to a playlist, but you just need to
    construct a Variant from the track ( I dont have to do this anywhere else)

    IITTrack next = itunes.getLibraryPlaylist().getTracks()
          .getItemByPersistentID(persistentId.getHighBit(), 
                                 persistentId.getLowBit());
    playlist.addTrack(new Variant(nextTrack));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I currently use a DataTable to get results from a database which I can
We currently use VSS 6, this is not going to change I am afraid.
I currently use nant, ccnet (cruise control), svn, mbunit. I use msbuild to do
I currently use subversion for my version control via AhnkSVN and Visual Studio. I
I currently use AnkhSVN to integrate subversion into Visual Studio. Is there any reason
I currently use my local web server to allow costumers to preview some applications
We currently use a hand-rolled setup and configuration script and a hand-rolled continuous integration
I currently use the following command, but it's a little unwieldy to type. What's
I currently use Notepad++ for most of my development. I have been checking out
We currently use LoadRunner for performance testing our web apps, but we also have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.