Пример #1
0
void CMediaPlayerDlg::StartSeekTimer()
{
    // Cancel any pending timer event
    StopSeekTimer();

    // Create a new timer
    g_wTimerID = SetTimer(MP_TIMERID, MP_TICKLEN, NULL);
}
Пример #2
0
void StartSeekTimer() 
{
    // Cancel any pending timer event
    StopSeekTimer();

    // Create a new timer
    g_wTimerID = SetTimer(g_hwnd, TIMERID, TICKLEN, NULL);
}
Пример #3
0
void CMediaPlayerDlg::OnPause()
{

    if (g_psCurrent_MP == State_Paused)
    {
        MPRunMedia();
        StartSeekTimer();


    }
    else
    {
        StopSeekTimer();
        MPPauseMedia();


    }
}
Пример #4
0
void CMediaPlayerDlg::OnStop()
{
    HRESULT hr;

    if (!pMC_MP || !pMS_MP)
        return;

    // Stop playback immediately with IMediaControl::Stop().
    StopSeekTimer();
    MPStopMedia();

    // Wait for the stop to propagate to all filters
    OAFilterState fs;
    hr = pMC_MP->GetState(500, &fs);
    if (FAILED(hr))
    {
        MPRetailOutput(TEXT("Failed to read graph state!  hr=0x%x\r\n"), hr);
    }

    // Reset to beginning of media clip
    LONGLONG pos=0;
    hr = pMS_MP->SetPositions(&pos, AM_SEEKING_AbsolutePositioning ,
                              NULL, AM_SEEKING_NoPositioning);
    if (FAILED(hr))
    {
        MPRetailOutput(TEXT("Failed to seek to beginning of media!  hr=0x%x\r\n"), hr);
    }

    // Display the first frame of the media clip, if it contains video.
    // StopWhenReady() pauses all filters internally (which allows the video
    // renderer to queue and display the first video frame), after which
    // it sets the filters to the stopped state.  This enables easy preview
    // of the video's poster frame.
    hr = pMC_MP->StopWhenReady();
    if (FAILED(hr))
    {
        MPRetailOutput(TEXT("Failed in StopWhenReady!  hr=0x%x\r\n"), hr);
    }



    // Reset slider bar and position label back to zero
    ReadMediaPosition();
}
Пример #5
0
HRESULT CMediaPlayerDlg::FreeDirectShow(void)
{
    HRESULT hr=S_OK;

    StopSeekTimer();
    MPStopMedia();

    // Remember the current volume slider position so that the
    // same volume level can be applied to the next clip
    HandleVolumeSlider(0);

    // Disable event callbacks
    if (pME_MP)
        hr = pME_MP->SetNotifyWindow((OAHWND)NULL, 0, 0);

    // Hide video window and remove owner.  This is not necessary here,
    // since we are about to destroy the filter graph, but it is included
    // for demonstration purposes.  Remember to hide the video window and
    // clear its owner when destroying a window that plays video.
    if(pVW_MP)
    {
        hr = pVW_MP->put_Visible(OAFALSE);
        hr = pVW_MP->put_Owner(NULL);
    }

    SAFE_RELEASE(pMC_MP);
    SAFE_RELEASE(pMS_MP);
    SAFE_RELEASE(pVW_MP);
    SAFE_RELEASE(pBV_MP);
    SAFE_RELEASE(pME_MP);
    SAFE_RELEASE(pGB_MP);
    SAFE_RELEASE(pBA_MP);


    return hr;
}