Hi all
I need to code a simple program in C++ that reacts to itunes triggered events, such as "the user pressed play".
Following a few examples i managed to get itunes listening to events. However, I do not know how to do this:
-Be in "waiting" mode until an event triggered...
-When an event is triggered, just do "whatever".
-Once "whatever" is finished, go back to "waiting" mode to wait for new events...
Right now, if I connect to the event handler as follows, the program exits before I can trigger any event from itunes:
IConnectionPointContainer* icpc;
IConnectionPoint* icp;
CiTunesEventHandler* eventHandler;
DWORD dwAdvise;
eventHandler = new CiTunesEventHandler();
piTunes->QueryInterface(IID_IConnectionPointContainer, (void **)&icpc);
icpc->FindConnectionPoint(DIID__IiTunesEvents, &icp);
icpc->Release();
icp->Advise(eventHandler,&dwAdvise);
icp->Release();
If I tried this infinite loop:
for(;;)
icp->Advise(eventHandler,&dwAdvise);
it works until the first event is triggered, and then it goes mad, blocks itunes and keeps triggering the same event again and again...
Any ideas of how to constantly wait for new events without exiting the program or blocking everything???
Thanks a lot for your help!!!!
pj