Exemplo n.º 1
0
DWORD WINAPI movieThread(LPVOID param)
{
	CMovie *lpMov = (CMovie *)param;

	while(FALSE==lpMov->bExitMovieThread){
		lpMov->DecodeMovie();
	}
	lpMov->Release();
	CloseHandle(lpMov->hMovieThread);
	lpMov->hMovieThread = NULL;
	ExitThread(TRUE);
	return 0L;
} // movieThread
Exemplo n.º 2
0
//-------------------------------------------------------------------------
//      Name:   CmdAddMovie
//      Desc:   Processes command "add movie" from the parent dialog
//      Parameters:     (sMovieInfo *)lParam;
//      Return:
//      Other:   1. Create CMovie
//               2. Add movie to the end of the list
//               3. Start playing
//-------------------------------------------------------------------------
void CMultiSAP::CmdAddMovie(sMovieInfo* pMovInf)
{

    HRESULT hr = S_OK;
    RECT rc;
    CMovie *pmovie = NULL;

    CAutoLock Lock(&m_AppImageLock);

    CmdAddEffect(eEffectFading,2000, 300, 400, TRUE); // set next videoeffect "fading"

    if( m_pEffect ) // ping video effect change
    {
        m_pEffect->Finish();
    }

    if( !pMovInf)
    {
        OutputDebugString(TEXT("Invalid parameter sent to CmdAddMovie()\n"));
        return;
    }

    if( 0 == m_movieList.GetSize() )
    {
        ShowWindow( m_hwndApp, SW_SHOW);
    }

    pmovie = new CMovie;
    if( !pmovie )
    {
        OutputDebugStringA("Failed to allocate new movie in CmdAddMovie()\n");
        return;
    }
    pmovie->Initialize(pMovInf, this);

    if( FALSE == m_movieList.Add( pmovie ))
    {
        OutputDebugStringA("Failed to add new movie to the list in CmdAddMovie()\n");
        pmovie->Release();
        delete pmovie;
        return;
    }

    try
    {
        if( !m_movieList.GetMovie( pMovInf->pdwUserID) )
            throw;
        hr = m_movieList.GetMovie( pMovInf->pdwUserID)->OpenMovie();
    }
    catch(...)
    {
        pmovie->Release();
        delete pmovie;
        OutputDebugString(TEXT("Unhandled exception when trying to open the movie\n"));
        hr = E_POINTER;
    }

    if( FAILED(hr))
    {
        m_movieList.Delete( pMovInf->pdwUserID );

        if( m_bErrorMessage )
        {
            MessageBox(NULL, m_achErrorMessage, m_achErrorTitle, MB_ICONEXCLAMATION);
            m_bErrorMessage = false;
        }
        else
        {
#ifdef UNICODE
            hr = StringCchPrintfW( m_achErrorMessage, NUMELMS(m_achErrorMessage),TEXT("Direct3D object returned error code 0x%08x.\r\n"), hr);
#else
            hr = StringCchPrintf( m_achErrorMessage, NUMELMS(m_achErrorMessage),TEXT("Direct3D object returned error code 0x%08x.\r\n"), hr);
#endif
            hr = StringCchCat( m_achErrorMessage,  NUMELMS(m_achErrorMessage), TEXT("Please use DirectX Error Lookup tool and verify DirectX\r\n")\
                                          TEXT("capabilities of your video driver. We are sorry for inconvenience.\r\n")\
                                          TEXT("You may want to try a different media file, or try a different video driver."));

            hr = StringCchCopy( m_achErrorTitle, MAX_PATH, TEXT("Error when trying to render media file"));

            MessageBox(NULL, m_achErrorMessage, m_achErrorTitle, MB_ICONEXCLAMATION);
            m_bErrorMessage = false;
        }
        return;
    }

    GetMoviePosition(&rc);
    PutMoviePosition(rc);

    if( m_pEffect )
    {
        m_pEffect->Invalidate();
    }
    try
    {
        hr = PlayMovie(pMovInf->pdwUserID);
    }
    catch(...)
    {
        OutputDebugString(TEXT("Failed to start movie\n"));
        m_movieList.Delete( pMovInf->pdwUserID );
        hr = E_FAIL;
    }

    if( FAILED(hr))
    {
        m_movieList.Delete( pMovInf->pdwUserID );
    }
}