How can I destroy the video window?
-
I wrappered a class to play video using DirectShow, almost following the sample "playwnd", but i found it cannot destroy the media window by the destructor, unless I destroy the parent window. I checked the state of the player window, it was stopped, but I could still saw it was running after the destructor invoked...:( Following list the destructor, what is the problem?
CMediaPlay::~CMediaPlay(void) { HRESULT hr; if (m_pMediaControl) { LIF( m_pMediaControl->Stop()); OAFilterState fs; LIF( m_pMediaControl->GetState(200L, &fs)); if (fs == State_Stopped) Msg(_T("Successfully stopped the filter run")); } // Relinquish ownership (IMPORTANT!) after hiding video window if(m_pVideoWindow) { LIF(m_pVideoWindow->put_Visible(OAFALSE)); LIF(m_pVideoWindow->put_Owner(NULL)); } // Disable event callbacks if (m_pMediaEventEx) LIF(m_pMediaEventEx->SetNotifyWindow((OAHWND)NULL, 0, 0)); #ifdef REGISTER_FILTERGRAPH if (g_dwGraphRegister) { RemoveGraphFromRot(g_dwGraphRegister); g_dwGraphRegister = 0; } #endif SAFE_RELEASE(m_pFileSource ); SAFE_RELEASE(m_pVideoDecoder ); SAFE_RELEASE(m_pAVISplitter ); SAFE_RELEASE(m_pSourceReader ); SAFE_RELEASE(m_pMediaEventEx ); SAFE_RELEASE(m_pMediaSeeking ); SAFE_RELEASE(m_pVideoFrameStep ); SAFE_RELEASE(m_pMediaControl ); SAFE_RELEASE(m_pBasicAudio ); SAFE_RELEASE(m_pBasicVideo ); SAFE_RELEASE(m_pVideoWindow ); SAFE_RELEASE(m_pGraphBuilder ); }
|-|3llo Wo|2ld