Jump to content


Photo
- - - - -

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


  • Please log in to reply
7 replies to this topic

#1 solyoung

solyoung
  • Member
  • 4 posts

Posted 13 January 2006 - 05:54 PM

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

#2 Millennium

Millennium
  • Member
  • 368 posts

Posted 13 January 2006 - 07:37 PM

NEED TAG!

Got iTUNES, why ppl need this code anyway? Life is hard, why making it harder, make it easire;)
  • 0

#3 solyoung

solyoung
  • Member
  • 4 posts

Posted 13 January 2006 - 08:14 PM

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

#4 herd

herd
  • Developers
  • 999 posts

Posted 16 January 2006 - 09:58 AM

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

#5 solyoung

solyoung
  • Member
  • 4 posts

Posted 23 January 2006 - 08:03 PM

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

#6 Bhavna

Bhavna
  • Member
  • 2 posts

Posted 04 March 2006 - 01:11 PM

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

#7 solyoung

solyoung
  • Member
  • 4 posts

Posted 04 March 2006 - 04:48 PM

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

#8 tcliao

tcliao
  • Member
  • 1 posts

Posted 09 April 2008 - 06:11 PM

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