// // Toggle the pause state for the media player. Returns true if the media player pauses, false if it runs. // bool CMediaPlayer::TogglePauseState() { bool isPaused = false; IMediaControl *mediaControl; HRESULT hr = _GraphBuilder->QueryInterface(IID_PPV_ARGS(&mediaControl)); if (SUCCEEDED(hr)) { OAFilterState filterState; hr = mediaControl->GetState(INFINITE, &filterState); if (SUCCEEDED(hr)) { if (filterState == State_Running) { mediaControl->Pause(); isPaused = true; } else if (filterState == State_Paused) { mediaControl->Run(); isPaused = false; } } mediaControl->Release(); } return isPaused; }
bool DirectShowUtil::FilterGrapph_Pause(IGraphBuilder *pFilterGraph) { bool bRet=false; if(pFilterGraph){ IMediaControl *pControl = GetMediaControl(pFilterGraph); if(pControl){ HRESULT hr = pControl->Pause(); SAFE_RELEASE(pControl); bRet = true; } } return bRet; }
// // Pauses media playback if it is currently running. // bool CMediaPlayer::Pause() { bool isPaused = false; IMediaControl *mediaControl; HRESULT hr = _GraphBuilder->QueryInterface(IID_PPV_ARGS(&mediaControl)); if (SUCCEEDED(hr)) { mediaControl->Pause(); mediaControl->Release(); isPaused = true; } _Playing = false; return isPaused; }
void CTsReaderFilter::SetMediaPosition(REFERENCE_TIME MediaPos) { { CAutoLock cObjectLock(&m_GetTimeLock); m_MediaPos = MediaPos ; m_BaseTime = (REFERENCE_TIME)GetTickCount() * 10000 ; // m_pClock->GetTime(&m_BaseTime) ; m_LastTime=m_BaseTime ; } // LogDebug("SetMediaPos : %f %f",(float)MediaPos/10000,(float)m_LastTime/10000) ; // This is not really the right place, but this is the only method called by "MPmain" that could allow // TsReader to "Pause" itself without deadlock issue. // This is also here to allow compatibility with previous releases, avoiding a new callback from MP. if (m_bRenderingClockTooFast) { if (m_bPauseOnClockTooFast) return ; // Do not re-enter ! if (GetCurrentThreadId()!=m_MPmainThreadID) return ; // Only MPmain can do that ! if (((m_MediaPos/10000)-m_absSeekTime.Millisecs()) < 30*1000) { return ; } m_bPauseOnClockTooFast=true ; if (State() == State_Running) { IMediaControl * ptrMediaCtrl; if (SUCCEEDED(GetFilterGraph()->QueryInterface(IID_IMediaControl, (void**)&ptrMediaCtrl))) { LogDebug("Pause 200mS renderer clock to match provider/RTSP clock...") ; ptrMediaCtrl->Pause() ; Sleep(200) ; // m_TestTime = GetTickCount() ; ptrMediaCtrl->Run() ; m_bRenderingClockTooFast=false ; } else LogDebug("Pause failed...") ; } m_bPauseOnClockTooFast=false ; } }
void PlaybackControls::PlayPause() { IMediaControl *pControl = NULL; FILTER_STATE fs; HRESULT hr; if (mpGraph) { hr = mpGraph->QueryInterface(IID_IMediaControl, (void **)&pControl); pControl->GetState(50, (OAFilterState*)&fs); if (fs == State_Running) pControl->Pause(); else pControl->Run(); pControl->Release(); } }
bool CHogVideo::Hog() { if (!m_pGraph && !m_pMediaControl && !m_pVideoWindow) return false; this->UnHog(); HRESULT hr = NULL; IGraphBuilder *pGraph = (IGraphBuilder*) m_pGraph; IMediaControl *pMediaControl = (IMediaControl*) m_pMediaControl; IVideoWindow *pVideoWindow = (IVideoWindow*) m_pVideoWindow; // Build the graph. IMPORTANT: Change string to a file on your system. hr = pGraph->RenderFile(m_wszFilename, NULL); if (SUCCEEDED(hr)) { // Run the graph. hr = pMediaControl->Run(); // Hide the window pVideoWindow->put_WindowState(SW_HIDE); pVideoWindow->put_AutoShow(OAFALSE); pVideoWindow->put_Visible(OAFALSE); pVideoWindow->put_Top(-100); pVideoWindow->put_Left(-100); pVideoWindow->put_Width(0); pVideoWindow->put_Height(0); if (SUCCEEDED(hr)) { // Hog the resource. pMediaControl->Pause(); return true; } else return false; } else return false; }