Itunes and Quicktime in C++

Discussion in 'Mac Programming' started by frozenrain, Apr 18, 2008.

  1. frozenrain macrumors newbie

    Joined:
    Apr 4, 2008
    #1
    Hello all, These forums have been really helpfull in the past so I am trying my luck again here:p

    I am trying to use the quicktime sdk and itunes sdk in Visual C++. My Visual C++ skills are not nearly as strong as I would like them to be. I am going out later tonight to pick up some books but I am hoping this site can help me too.


    I have read most of the documentation on the sdks and understand the commands I believe. I have also added the .H files I believe i need to the headers location. Now I am just having trouble getting the program to reconize anything as my includes don't seem to work.

    iTunesAPI.h
    iTunesCOMInterface.h
    iTunesVisualAPI.h

    Those are the three header files i am using so far. They didn't come with any resorce files that I can see, in fact im honestly not even sure if visual c++ uses the resorce files like normal c++ as I am that new to it.

    bassiclly what I need help with is getting c++ to reconize the files so i can start using the commands. Being able to access the itunes library and adding a quicktime movie control/box should be enough to get me on my path if anyone can help.


    Also how transferable is Visual c++ code to a mac? Is there a program anyone would recomend for programing with quicktime and itunes for the mac? I have to make this program workable for both pc and mac.


    Thanks for your help. I am only on my second year of school so this is all just barely above my level of knowlege but hopefully I can do it with some help:p

    Thanks again.
     
  2. Cromulent macrumors 603

    Cromulent

    Joined:
    Oct 2, 2006
    Location:
    The Land of Hope and Glory
    #2
    First of all it sounds like you need to sit down and read the Visual C++ IDE documentation. It shouldn't take long and learning your IDE saves ALOT of hassle later on.

    Developing on the Mac you would use Xcode, it is pretty much the same idea as Visual C++ except it is more Unixy. Both are good IDEs as they go though.

    As long as you are writing decent C++ and keep the platform dependant parts of your code independent then you should be fine.
     
  3. kainjow Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
    #3
    Last time I checked (not long ago) the QuickTime 7 SDK includes all the CoreFoundation types, which is what the Mac uses. If you stick with using these data types, then you're in good shape. It might take some learning since it's a new API, but it's worth it. Especially if you're wanting to read the iTunes Library.xml file. CFDictionary will read that for you automatically, without having to parse the XML yourself.

    I don't think you need to worry about any resource files for QuickTime in VS. Just make sure VS can see the .lib and .h files inside the QT SDK folder, and you should be good to go.
     
  4. frozenrain thread starter macrumors newbie

    Joined:
    Apr 4, 2008
    #4
    Thanks for the help, I did learn a bit from that. Right now the current problem I am getting is this error when trying to build

    Command line error D8045 : cannot compile C file '..\..\..\itunesinteract\itunes_interact_src\iTunesCOMInterface_i.c' with the /clr option


    anyone know what the hell that means? Thanks again for the help
     
  5. Gelfin macrumors 68020

    Gelfin

    Joined:
    Sep 18, 2001
    Location:
    Denver, CO
    #5
    You're trying to compile the iTunes API in such a way it's compatible with managed (.NET) code. Straight-up C code cannot be compiled this way. You have to compile it as C++. Try Project Properties -> C/C++ -> Advanced -> Compile As to force C++ compilation.
     
  6. frozenrain thread starter macrumors newbie

    Joined:
    Apr 4, 2008
    #6
    Thank you.


    Thank you very much, I have spent approxamitly 13 hours give or take a few trying to figure this out:( That solved all my problems of trying to include all the sdk's I needed. Thank you again very much. Now all i have is the daunting task of learning all the commands capable that I will need to use:)

    For future referance of anyone who might be helped by this, I also had to add stdafx header to the .c file and had to comment out two other headers that were already there.
     
  7. frozenrain thread starter macrumors newbie

    Joined:
    Apr 4, 2008
    #7
    I thought I had everything working untill i went to debug and run the program:) WHen building the solution everything was building properlly, however when i went to debug it seems as if it is not communicating with itunes and gives me an error to abort, contiue or quit.

    I belive it was because i was missing this line


    hRes = ::CoCreateInstance(CLSID_iTunesApp, NULL, CLSCTX_LOCAL_SERVER, IID_IiTunes, (PVOID *)&pITunes);

    however when I add this line in it dosn't like the CLSID_iTunesApp, or the IID_IiTunes, i can't figure out why. It gives me this error,

    Error 9 error LNK2020: unresolved token (0A000011) CLSID_iTunesApp testing.obj testing

    In an example I found It appears as if they got around this with the following code segment.

    "
    // TODO: Add your control notification handler code here
    CoInitialize(NULL);
    HRESULT hr;
    CComPtr<IiTunes> spITunesApp;

    // note - CLSID_iTunesApp and IID_IiTunes are defined in iTunesCOMInterface_i.c
    //create iTunes component
    hr = ::CoCreateInstance(CLSID_iTunesApp,
    NULL, CLSCTX_LOCAL_SERVER,//local server
    __uuidof(spITunesApp),
    (void **)&spITunesApp);


    if(FAILED(hr))
    {
    AfxMessageBox("Failed to load iTunes Component, is iTunes installed????");
    return;
    }
    "
    When I modify that code the only problem I am having is with the "CComPtr", it dosn't reconize that and I have no idea what it is or what header file it comes from.


    Anyone out there have any experiance with this?


    Thanks.
     
  8. Sander macrumors 6502

    Joined:
    Apr 24, 2008
    #8
    I don't have experience with programming iTunes stuff, but I do COM on an almost daily base. CComPtr is part of ATL (Active Template Library). Visual Studio has pre-cooked linking settings to include ATL. You may also have to #include stuff like atlcom.h.

    cps2009: Adding a (header) file to the project is not sufficient for the compiler to actually find it. You'll have to make sure it's located in a directory which is part of the header file search path.

    By the way: the code I'm seeing looks like COM, which makes it tied to Windows. I don't think you can (easily) make your program work on the Mac as well, if you take this route. There's probably a different (Objective-C) way of doing things on the Mac side.
     

Share This Page