I was trying to \"just quickly integrate\" the Windows Media Player via COM to play single files from the local file system or http sources - but due to the sparse
WMP supports two automation methods, embedded ActiveX or COM server. For embedded use, you add the ActiveX via an object tag (execute some scripts via IHTMLWindow2 from your BHO/Band) or a hidden form and automate from there. See Using the Windows Media Player Control in a Web Page and Hosting the Windows Media Player Control in a Windows Application for sample codes.
For COM server use, just create the player as COM server and automate from it. You can either make it a UI-less playback engine, or remote it so you have a full UI.
Windows Media Player plays asynchronously, for example, it could call IMediaControl::Run and return immediately when you call put_URL (another immediate call to play would fail because it is already playing). If you do not need the automatic playing, I guess you need IWMPSettings::put_autoStart.
WMP assumes itself to be in the main thread. If you are in a worker thread or a MTA thread, I suggest you span another process to automate it, or remote it as an out-of-proc server.
After further investigation, it turned out that this was actually caused by a VS2005 workaround for VS2008s AtlSetPerUserRegistration()
which was always active - but should have been only for the contained COM servers registration/unregistration.
The workaround overrides HKEY_LOCAL_MACHINE
with HKEY_CURRENT_USER
, which obviously results in quite some components failing if they are created in-process.