IWMPPlayer(4)/COM issues
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: IWMPPlayer(4)/COM issues

  1. #1
    Join Date
    Mar 2009

    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:
    #include <iostream>
    #include <windows.h>
    #import "wmp.dll" no_namespace named_guids high_method_prefix( "I" )
    using namespace std;
    int main()
    	IWMPPlayer4* player;
    	HRESULT res = CoCreateInstance(CLSID_WindowsMediaPlayer, NULL, CLSCTX_INPROC_SERVER, IID_IWMPPlayer4, (void**)&player);
    	if (SUCCEEDED(res))
    		IWMPSettings* settings;
    		cout << settings->put_mute(TRUE) << endl;
    	return 0;
    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.

    Thanks in advance.
    Last edited by GeneR; March 1st, 2009 at 09:46 PM.

  2. #2
    Join Date
    Mar 2009

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Azure Activities Information Page

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


HTML5 Development Center