Пример #1
0
void OpenFiles(void)
{
    HRESULT hr;

    // Display a custom file selection dialog to get both filenames
    DialogBox(ghInst, MAKEINTRESOURCE(IDD_DIALOG_FILES),
              ghApp,  (DLGPROC) FilesDlgProc);

    // If user clicked OK, then open the files
    if (g_bFilesSelected)
    {
        g_bFilesSelected = FALSE;

        // Initialize the global strParam structure with default values
        InitStreamParams();

        // Initialize DirectShow, render the files, and play the streams
        hr = BlendVideo(g_szFile1, g_szFile2);

        // If we couldn't play the streams, clean up
        if (FAILED(hr))
        {
            CloseFiles();
            return;
        }

        // Set video position, size, and alpha values
        UpdatePinPos(0);
        UpdatePinPos(1);
        UpdatePinAlpha(0);
        UpdatePinAlpha(1);
    }
}
Пример #2
0
/******************************Public*Routine******************************\
* VcdPlayerOpenCmd
*
\**************************************************************************/
BOOL
VcdPlayerOpenCmd(
    int strmID
    )
{
    static BOOL fFirstTime = TRUE;
    BOOL fRet;
    TCHAR achFileName[MAX_PATH];
    TCHAR achFilter[MAX_PATH];
    LPTSTR lp;

    if(fFirstTime)
    {
        ofn.lStructSize = sizeof(ofn);
        ofn.hwndOwner = hwndApp;
        ofn.Flags = OFN_HIDEREADONLY | OFN_FILEMUSTEXIST |
            OFN_SHAREAWARE | OFN_PATHMUSTEXIST;
    }

    lstrcpy(achFilter, IdStr(STR_FILE_FILTER));
    ofn.lpstrFilter = achFilter;

    /*
    ** Convert the resource string into to something suitable for
    ** GetOpenFileName ie.  replace '#' characters with '\0' characters.
    */
    for(lp = achFilter; *lp; lp++)
    {
        if(*lp == TEXT('#'))
        {
            *lp = TEXT('\0');
        }
    }

    ofn.lpstrFile = achFileName;
    ofn.nMaxFile = sizeof(achFileName) / sizeof(TCHAR);
    ZeroMemory(achFileName, sizeof(achFileName));

    fRet = GetOpenFileName(&ofn);
    if(fRet)
    {
        if(strmID == 0)
        {
            fFirstTime = FALSE;
            ProcessOpen(achFileName);
        }
        else
        {
            if(pMpegMovie)
            {
                pMpegMovie->RenderSecondFile(achFileName);
            }
        }

        InitStreamParams(strmID);
    }

    return fRet;
}
Пример #3
0
/******************************Public*Routine******************************\
* ProcessOpen
*
\**************************************************************************/
void
ProcessOpen(
    TCHAR *achFileName,
    BOOL bPlay
    )
{
    /*
    ** If we currently have a video loaded we need to discard it here.
    */
    if(g_State & VCD_LOADED)
    {
        VcdPlayerCloseCmd();
    }

    lstrcpy(g_achFileName, achFileName);

    pMpegMovie = new CMpegMovie(hwndApp);
    if(pMpegMovie)
    {
        HRESULT hr = pMpegMovie->OpenMovie(g_achFileName);
        if(SUCCEEDED(hr))
        {
            TCHAR achTmp[MAX_PATH];

            nRecentFiles = SetRecentFiles(achFileName, nRecentFiles);

            wsprintf(achTmp, IdStr(STR_APP_TITLE_LOADED),
                g_achFileName);
            g_State = (VCD_LOADED | VCD_STOPPED);

            // SetDurationLength(pMpegMovie->GetDuration());
            g_TimeFormat = VcdPlayerChangeTimeFormat(g_TimeFormat);

            RepositionMovie(hwndApp);
            pMpegMovie->SetBorderClr(RGB(0x00, 0x80, 0x80));

            //  If play
            if(bPlay)
            {
                pMpegMovie->PlayMovie();
            }
        }
        else
        {
            TCHAR Buffer[MAX_ERROR_TEXT_LEN];

            if(AMGetErrorText(hr, Buffer, MAX_ERROR_TEXT_LEN))
            {
                MessageBox(hwndApp, Buffer,
                    IdStr(STR_APP_TITLE), MB_OK);
            }
            else
            {
                MessageBox(hwndApp,
                    TEXT("Failed to open the movie.  Either the file was ")
                    TEXT("not found or the wave device is in use."),
                    IdStr(STR_APP_TITLE), MB_OK);
            }

            pMpegMovie->CloseMovie();
            delete pMpegMovie;
            pMpegMovie = NULL;
        }
    }

    InitStreamParams(0);

    InvalidateRect(hwndApp, NULL, FALSE);
    UpdateWindow(hwndApp);
}