March 1st, 2009, 09:08 PM
IWMPPlayer4 issues (COM)
Hi all, I'm brand new to COM development and I'm trying to have a simple program control a WMP instance. In the following example, the code is supposed to launch WMP and load the specified streaming URL, wait for user input, mute the sound, wait for user input and then close WMP. However, what actually ends up happening is the player launches and loads the URL correctly, but the mute and close commands are ignored (even though put_mute returns 0/S_OK). Here is the code:
Does this have anything to do with the fact I'm trying to do this from within a console app? If so, what part of a Win32 app is needed for IWMPPlayer4 to work correctly (e.g. is it the message loop, etc)? Also, I am using VS2008 EE.
#import "wmp.dll" no_namespace named_guids high_method_prefix( "I" )
using namespace std;
HRESULT res = CoCreateInstance(CLSID_WindowsMediaPlayer, NULL, CLSCTX_INPROC_SERVER, IID_IWMPPlayer4, (void**)&player);
cout << settings->put_mute(TRUE) << endl;
Thanks in advance.
Last edited by GeneR; March 1st, 2009 at 09:46 PM.
March 2nd, 2009, 10:56 AM
Re: IWMPPlayer(4)/COM issues
Indeed, my suspicions were correct -- I needed the message loop (but beyond that console apps seem to work fine). I just added the Get/Translate/Dispatch triplet at the end of the if condition and everything worked.
Last edited by GeneR; March 2nd, 2009 at 12:22 PM.
Click Here to Expand Forum to Full Width
This is a CodeGuru survey question.