Sign in to follow this  
Followers 0

Adding tracks to iPod with Windows COM SDK (C++)

8 posts in this topic

Is it possible to use the Windows COM SDK to add tracks to iPod's playlist (or even modify them, etc? iTunes is throwing an exception when I attempt to call AddTrack on an IITLibraryPlaylist object acquired from an iPod...

Here's the code...

// this works

CComPtr newPlaylist = app()->CreatePlaylist(playlistName);

if (FAILED(newPlaylist->QueryInterface(&newUPlaylist)) || !newUPlaylist) {

std::cerr << "ERROR: Could not create playlist '" << playlistName << "'." << std::endl;

_com_issue_errorex(hr, app(), __uuidof(app()));

}

CComVariant cv(i->track());

CComPtr newTrack = newUPlaylist->AddTrack(&cv);

// this blows up at the AddTrack call (everything before that works fine)

CComPtr sources = app()->GetSources();

CComPtr iPod = sources->GetItem(ipodSourceNum);

CComPtr iPodPlaylists = iPod->GetPlaylists();

CComPtr iPodPlaylist = iPodPlaylists->GetItem(1);

std::cout << "iPod Playlist: " << iPodPlaylist->GetName() << std::endl;

CComPtr iPodUPlaylist;

if( FAILED(iPodPlaylist->QueryInterface(&iPodUPlaylist)) || !iPodUPlaylist )

std::cerr << "ERROR: Could not query iPod playlist interface" << std::endl;

CComPtr iPodNewTrack = iPodUPlaylist->AddTrack(&cv); // boom

0

Share this post


Link to post
Share on other sites

True, but I want to make an application which automatically imports mp3s from a memory card when it is inserted in to my computer and then have my application import only the music which wasn't already there... as well as move those files to the iPod.

iTunes can read my mind, but even my mind doesn't know what it wants sometimes.

0

Share this post


Link to post
Share on other sites

I guess its because you confuse the smart pointers with their bare bones COM counterparts.

Try these lines:

CCom[B]QI[/B]Ptr<IITLibraryPlaylist> iPodUPlaylist = iPodPlayList;

if( !iPodUPlaylist )

std::cerr << "ERROR: Could not query iPod playlist interface" << std::endl;

If this really fails, then the iPod playlist does not implement the standard playlist interface and you'll have to find another way (in the COM API) to upload your songs to your iPod.

hth,

herd

0

Share this post


Link to post
Share on other sites

As it turns out, the code was correct all the time... But iTunes, until their latest release, throws an exception when attempting to add tracks or files to the iPod Shuffle. When using a standard iPod, everything worked fine.

Cheers! Sol

0

Share this post


Link to post
Share on other sites

Hello everyone,

I am a C++ programmer, and am trying to write an IPod transfer utility.

In this utility i wanted to use the ITunes Windows COM SDK and the IPodService.

I could easily find the ITunes Windows COM SDK but where can i find some proper documentation on using the IPodService? On using the ITunes Windows COM SDK, the worst part is that the ITunes keep launching in the background, which i d not want to happen. I want to somehow make the ITunes not show up in the foreground, but stll do the processing.

Can someone guide me on this ? I need this help urgently.

Any help will be appreciated.

Is there any sample code available that will give a good IPod transfer utility using the Itunes COM Windows SDK.

Bhavna

0

Share this post


Link to post
Share on other sites

The iTunes COM API is for controlling iTunes as it exists on the user's PC. You can not gain its functionality without instantiating a visible version. To get around this you can do some of the standard windows API stuff (hiding the window, minimizing it, moving it off screen, etc).

0

Share this post


Link to post
Share on other sites

Did any one have successfully added file/track thru the iTunes COM SDK to iPod Shuffle?

I tried to add it into main library then add the added track to iPod Shuffle, yet, no matter how I tried, the AddFile() will return 0xA0040203 (ITUNES_E_OBJECTLOCKED)

Any idea?

0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0