示例#1
0
LRESULT CALLBACK FilesDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    static TCHAR szFile[MAX_PATH]={0};

    switch (message)
    {
        case WM_INITDIALOG:
            SetDlgItemText(hWnd, IDC_EDIT_FILE1, g_szFile1);
            SetDlgItemText(hWnd, IDC_EDIT_FILE2, g_szFile2);
            return TRUE;

        case WM_COMMAND:
            switch (wParam)
            {
                case IDCANCEL:
                    g_bFilesSelected = FALSE;
                    EndDialog(hWnd, TRUE);
                    break;

                case IDOK:
                    GetDlgItemText(hWnd, IDC_EDIT_FILE1, g_szFile1, MAX_PATH);
                    GetDlgItemText(hWnd, IDC_EDIT_FILE2, g_szFile2, MAX_PATH);

                    if ((g_szFile1[0] == 0) || (g_szFile2[0] == 0))
                    {
                        Msg(TEXT("Please provide two valid media filenames."));
                    }
                    else
                    {
                        g_bFilesSelected = TRUE;
                        EndDialog(hWnd, TRUE);
                    }
                    break;

                case IDC_BUTTON_FILE1:
                    if (GetClipFileName(szFile))
                        SetDlgItemText(hWnd, IDC_EDIT_FILE1, szFile);
                    break;

                case IDC_BUTTON_FILE2:
                    if (GetClipFileName(szFile))
                        SetDlgItemText(hWnd, IDC_EDIT_FILE2, szFile);
                    break;
            }
            break;
    }

    return FALSE;
}
示例#2
0
void OpenClip()
{
    HRESULT hr;

    // If no filename specified by command line, show file open dialog
    if(g_szFileName[0] == L'\0')
    {
        TCHAR szFilename[MAX_PATH];

        UpdateMainTitle();

        // If no filename was specified on the command line, then our video
        // window has not been created or made visible.  Make our main window
        // visible and bring to the front to allow file selection.
        InitPlayerWindow();
        ShowWindow(ghApp, SW_SHOWNORMAL);
        SetForegroundWindow(ghApp);

        if (! GetClipFileName(szFilename))
        {
            DWORD dwDlgErr = CommDlgExtendedError();

            // Don't show output if user cancelled the selection (no dlg error)
            if (dwDlgErr)
            {
                Msg(TEXT("GetClipFileName Failed! Error=0x%x\r\n"), GetLastError());
            }
            return;
        }

        // This sample does not support playback of ASX playlists.
        // Since this could be confusing to a user, display a warning
        // message if an ASX file was opened.
        if (_tcsstr((_tcslwr(szFilename)), TEXT(".asx")))
        {
            Msg(TEXT("ASX Playlists are not supported by this application.\n\n")
                TEXT("Please select a valid media file.\0"));
            return;
        }

        lstrcpy(g_szFileName, szFilename);
    }

    // Reset status variables
    g_psCurrent = Stopped;
    g_lVolume = VOLUME_FULL;
    
    // Start playing the media file
    hr = PlayMovieInWindow(g_szFileName, FALSE);

    // If we couldn't play the clip, clean up
    if (FAILED(hr) && ( hr != NS_E_LICENSE_REQUIRED ) )
        CloseClip();
}
void OpenClip()
{
    HRESULT hr;

    // If no filename specified by command line, show file open dialog
    if(g_szFileName[0] == L'\0')
    {
        TCHAR szFilename[MAX_PATH];

        UpdateMainTitle();

        InitPlayerWindow();
        SetForegroundWindow(ghApp);

        if (! GetClipFileName(szFilename))
        {
            DWORD dwDlgErr = CommDlgExtendedError();

            // Don't show output if user cancelled the selection (no dlg error)
            if (dwDlgErr)
            {
                Msg(TEXT("GetClipFileName Failed! Error=0x%x\r\n"), GetLastError());
            }
            return;
        }

        // This sample does not support playback of ASX playlists.
        // Since this could be confusing to a user, display a warning
        // message if an ASX file was opened.
        if (_tcsnicmp(szFilename, TEXT(".asx"), 4) == 0)
        {
            Msg(TEXT("ASX Playlists are not supported by this application.\n\n")
                TEXT("Please select a valid media file.\0"));
            return;
        }

        StringCchCopy(g_szFileName, NUMELMS(g_szFileName), szFilename);
    }

    // Reset status variables
    g_psCurrent = Stopped;
    g_lVolume = VOLUME_FULL;
    EnableWatermarkMenu(TRUE);

    // Start playing the media file
    hr = PlayMovieInWindow(g_szFileName);

    // If we couldn't play the clip, clean up
    if (FAILED(hr))
        CloseClip();
}
示例#4
0
void OpenClip()
{
    HRESULT hr;

    // If no filename specified by command line, show file open dialog
    if(g_szFileName[0] == L'\0')
    {
        TCHAR szFilename[MAX_PATH];

        InitPlayerWindow();
        SetForegroundWindow(ghApp);

        if (! GetClipFileName(szFilename))
        {
            DWORD dwDlgErr = CommDlgExtendedError();

            // Don't show output if user cancelled the selection (no dlg error)
            if (dwDlgErr)
            {
                Msg(TEXT("GetClipFileName Failed! Error=0x%x\r\n"), GetLastError());
            }
            return;
        }

        // This sample does not support playback of ASX playlists.
        // Since this could be confusing to a user, display a warning
        // message if an ASX file was opened.
        if (_tcsstr((_tcslwr(szFilename)), TEXT(".asx")))
        {
            Msg(TEXT("ASX Playlists are not supported by this application.\n\n")
                TEXT("Please select a valid media file.\0"));
            return;
        }

        lstrcpyn(g_szFileName, szFilename, NUMELMS(g_szFileName));
    }

    EnableTickerMenu(TRUE);

    // Start playing the media file
    hr = PlayMovieInWindow(g_szFileName);

    // If we couldn't play the clip, clean up
    if (FAILED(hr))
        CloseClip();
}
示例#5
0
//-----------------------------------------------------------------------------
// InitDShowTextureRenderer : Create DirectShow filter graph and run the graph
//-----------------------------------------------------------------------------
HRESULT CDShowManager::InitDShowTextureRenderer()
{
	HRESULT hr = S_OK;
	IBaseFilter*    pFSrc;          // Source Filter
	IPin*           pFSrcPinOut;    // Source Filter Output Pin
	CTextureRenderer        *pCTR=0;        // DirectShow Texture renderer

	// Create the filter graph
	//if (FAILED(g_pGB->CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC)))
	//	return E_FAIL;

	hr = CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC, IID_IGraphBuilder, (void **)&m_pGB);
	if (FAILED(hr))
	{
		return E_FAIL;
	}

#ifdef REGISTER_FILTERGRAPH
	// Register the graph in the Running Object Table (for debug purposes)
	AddToROT(m_pGB);
#endif

	// Create the Texture Renderer object
	pCTR = new CTextureRenderer(NULL, &hr);
	if (FAILED(hr) || !pCTR)
	{
		delete pCTR;
		Msg(TEXT("Could not create texture renderer object!  hr=0x%x"), hr);
		return E_FAIL;
	}

	// Get a pointer to the IBaseFilter on the TextureRenderer, add it to graph
	m_pRenderer = pCTR;
	pCTR->AddRef();
	if (FAILED(hr = m_pGB->AddFilter(m_pRenderer, L"TEXTURERENDERER")))
	{
		Msg(TEXT("Could not add renderer filter to graph!  hr=0x%x"), hr);
		return hr;
	}

	// Determine the file to load based on windows directory
	// Use the standard win32 API to do this.
	TCHAR strFileName[MAX_PATH] = {0};
	WCHAR wFileName[MAX_PATH];

	if (! GetClipFileName(strFileName))
	{
		DWORD dwDlgErr = CommDlgExtendedError();

		// Don't show output if user cancelled the selection (no dlg error)
		if (dwDlgErr)
		{
			Msg(TEXT("GetClipFileName Failed! Error=0x%x\r\n"), GetLastError());
		}
		return E_FAIL;
	}

	strFileName[MAX_PATH-1] = 0;  // NULL-terminate
	wFileName[MAX_PATH-1] = 0;    // NULL-terminate

	//USES_CONVERSION;
	(void)StringCchCopyW(wFileName, NUMELMS(wFileName), T2W(strFileName));

	// Add the source filter to the graph.
	hr = m_pGB->AddSourceFilter (wFileName, L"SOURCE", &pFSrc);

	// If the media file was not found, inform the user.
	if (hr == VFW_E_NOT_FOUND)
	{
		Msg(TEXT("Could not add source filter to graph!  (hr==VFW_E_NOT_FOUND)\r\n\r\n")
			TEXT("This sample reads a media file from your windows directory.\r\n")
			TEXT("This file is missing from this machine."));
		return hr;
	}
	else if(FAILED(hr))
	{
		Msg(TEXT("Could not add source filter to graph!  hr=0x%x"), hr);
		return hr;
	}

	if (FAILED(hr = pFSrc->FindPin(L"Output", &pFSrcPinOut)))
	{
		Msg(TEXT("Could not find output pin!  hr=0x%x"), hr);
		return hr;
	}

#ifdef NO_AUDIO_RENDERER

	// If no audio component is desired, directly connect the two video pins
	// instead of allowing the Filter Graph Manager to render all pins.

	CComPtr<IPin> pFTRPinIn;      // Texture Renderer Input Pin

	// Find the source's output pin and the renderer's input pin
	if (FAILED(hr = pFTR->FindPin(L"In", &pFTRPinIn)))
	{
		Msg(TEXT("Could not find input pin!  hr=0x%x"), hr);
		return hr;
	}

	// Connect these two filters
	if (FAILED(hr = m_pGB->Connect(pFSrcPinOut, pFTRPinIn)))
	{
		Msg(TEXT("Could not connect pins!  hr=0x%x"), hr);
		return hr;
	}

#else

	// Render the source filter's output pin.  The Filter Graph Manager
	// will connect the video stream to the loaded CTextureRenderer
	// and will load and connect an audio renderer (if needed).

	if (FAILED(hr = m_pGB->Render(pFSrcPinOut)))
	{
		Msg(TEXT("Could not render source output pin!  hr=0x%x"), hr);
		return hr;
	}

#endif

	// Get the graph's media control, event & position interfaces
	m_pGB->QueryInterface(&m_pMC);
	m_pGB->QueryInterface(&m_pMP);
	m_pGB->QueryInterface(&m_pME);

	// Start the graph running;
	if (FAILED(hr = m_pMC->Run()))
	{
		Msg(TEXT("Could not run the DirectShow graph!  hr=0x%x"), hr);
		return hr;
	}


	return S_OK;
}
// Mesage handler for start box.
LRESULT CALLBACK Start(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
	switch (message)
	{
		case WM_COMMAND:
			if (LOWORD(wParam) == ID_EDITSTOCK) 
			{
				EndDialog(hDlg, LOWORD(wParam));
				if(GetClipFileName(file))
				{
					if(IsDlgButtonChecked(hDlg, IDC_CHECK1))
					{
						LoadStock(file);
					}
					else
						NewLoadStock(file);
				}
					
				DialogBox(hInst, (LPCTSTR)IDD_STOCKDLG, NULL, (DLGPROC)StockProc);
			}
			if (LOWORD(wParam) == ID_EDITWORK) 
			{
				EndDialog(hDlg, LOWORD(wParam));
				if(GetClipFileName(file))
				{
					if(IsDlgButtonChecked(hDlg, IDC_CHECK1))
					{
						LoadWork(file);
					}
					else
						NewLoadWork(file);
				}
				EndDialog(hDlg, LOWORD(wParam));
				DialogBox(hInst, (LPCTSTR)IDD_WORKDLG, NULL, (DLGPROC)WorkProc);
			}
			if (LOWORD(wParam) == ID_EDITDRUGS) 
			{
				EndDialog(hDlg, LOWORD(wParam));
				if(GetClipFileName(file))
				{
					if(IsDlgButtonChecked(hDlg, IDC_CHECK1))
					{
						LoadDrug(file);
					}
					else
						NewLoadDrug(file);
				}
				DialogBox(hInst, (LPCTSTR)IDD_DRUGDLG, NULL, (DLGPROC)DrugProc);
			}
			if (LOWORD(wParam) == IDCANCEL) 
			{
				EndDialog(hDlg, LOWORD(wParam));
				return TRUE;
			}
			break;
		case WM_DESTROY:
			PostQuitMessage(0);
			return TRUE;	
	}
    return FALSE;
}