Search code examples
visual-c++c++-cliaxwindowsmediaplayer

axWindowsMediaPlayer Visual C++ End of File


I have a problem handling the end of file state of the axWindows Media Player and then open another frame in Visual C++

Here is my function :

private: System::Void axWindowsMediaPlayer1_PlayStateChange(System::Object^  sender, AxWMPLib::_WMPOCXEvents_PlayStateChangeEvent^  e) {

                 if (e->newState == 8) {
                     this->Hide();
                     MainForm^ frame = gcnew MainForm();
                     frame->ShowDialog();

                 }
    }

If I build the project, the media player render the movie, plays it and when it reaches the end of file it's called the Hide function but the frame didn't show up. I receive no error.

What should I do or what I'm doing wrong ?


Solution

  • In this kind of situation you should try to catch an exception, and read its message - it's very helpful, and helps spare some time in the future.

    try 
    {
        ...
    }
    catch (System::Exception^ e)
    {
        System::Console::WriteLine(e->Message);
    }