INTERACT FORUM
Windows => Plug-in Development => Topic started by: neFAST on July 24, 2011, 04:22:02 pm
-
Hi folks, I'm working on a plugin this time in C++.
My previous plugin was in C# from M. Chriz templates and events were working like a charm.
But now I'm trying to write something using Qt and C++.
At first I tried to connect the FireEvent signal with a QAxObject from Qt, but I gave up.
I restarted a project from scratch with ATL only, and I still fail at intercepting events.
I have read http://wiki.jriver.com/index.php/Media_Center_Automation#Event_Handling 100 times but when tring
BEGIN_SINK_MAP(Bridge)
SINK_ENTRY_EX(1, DIID_IMJAutomationEvents, 1, handleJRMCEvent)
END_SINK_MAP()
I get this error:
error C2440: 'static_cast' : cannot convert from '_atl_event_classtype *' to 'ATL::_IDispEventLocator<nID,piid> *
What is wrong with my code?
Thanks a lot for your help with ATL guys (and if you have a solution that works with Qt it would be even better)
-
Finally found the way to do it thanks to Qt tool "dumpdoc.exe"
-
I removed the SOLVED tag in my thread since I have an issue.
If I call Play() on a PlaybackAutomationPtr from my plugin, it works correctly ...
... except if I call it from the function that is hooked to windows events.
In that specific case, the Play() call never returns: if I add a breakpoint to the next line of code, it is never reached!
Does Play() triggers an event that could be caught and wrongly handled by my event hook?
Thanks a lot for your help guys!
-
Using PlaybackAutomationPtr from a worker thread could cause trouble, because internally it sends messages to the player window. Especially if the handling of these messages fires an event that tries to re-enter your event handler.
Instead, I would recommend posting MCC messages to the player if you're in a worker thread.
For example:
PostMessage(MJ.GetWindowHandle(), WM_MC_COMMAND, MCC_PLAY_CPLDB_INDEX, -1);
-
Thanks for the tips. I'm not really used to working with events.
I double checked that my event hook is running in the main thread.
I have something working now.
Is there a way to detect :
- MC is closing?
- current track rating changed?
- current track lyrics changed?
- current track cover changed?
If I ask for the current track cover thumbnail (GetImageFile(IMAGEFILE_THUMBNAIL_MEDIUM) I guess that MC cleans up thumbnails once in a while, is it possible that the path becomes quickly invalid?
Thanks for your help Matt
EDIT: I thought I had something working but its wrong. Within my eventhandler I need to get MC current track position and return this as the result of the event. Can I do this with a PostMessage?