Search code examples
c++windows-media-player

How to use Windows Media Player?


I have an old application written in C++ 6.0. This application manages some sound for alarming purpose in a manufacturing environment.

Now I would like to make some modifications and use Windows Media Player. My knowledge of C++ limited. Kind of lost in the pointers...

This is what I managed to do so far:

Used the class wizard to add the wrapper classes to wmplib.dll and included "wmp.h". in the .cpp file.

IWMPPlayer *player = new IWMPPlayer();
//player.SetUrl("http://streampoint.radioio.com/streams/57/45ec8c85a2a8a/listen.pls");
player->SetEnabled(true);
player->SetUrl("C:\\tada.wav");

IWMPControls *pControls = new IWMPControls();
*pControls = player->GetControls();

pControls->play();  

Any suggestions?

Thanks


Solution

  • I Finally found a way.

    At first, I wanted to do it without having to include the WMP ActiveX in the View. So I ended up adding it and then use ClassWizard to create the associated Member variable in the View.

    The created member variable is of type CWNDPlayer4.

    Here is the code I used:

    m_BackgroundPlayer.SetUrl(m_Url);
    m_BackgroundPlayer.GetSettings().SetVolume(100);
    m_BackgroundPlayer.GetControls().play();
    

    m_Url is the member variable associated with a text box in which the user types the URL.

    I used Windows Media Player 10.00.00.4081 and my environment was Windows XP Pro SP3.