Skip to main content
gamedev.net
🔒 Locked

directshow problem

Started by killer13 May 11, 2004 at 3:44 PM 0 replies 300+ views
Original Post
killer13
killer13
ok i have tis code : void playMovie() { OPENFILENAME ofn; static char szFile[1024]; static char szFileTitle[1024]; memset(&ofn, 0, sizeof(ofn)); ofn.lStructSize = sizeof(ofn); ofn.hwndOwner = hWnd; ofn.lpstrFilter = "Movie Files\0*.avi;*.mpeg;*.mpg;*.asf;*.divx;*.dat\0\0"; ofn.lpstrFile = szFile; ofn.nMaxFile = sizeof(szFile); ofn.lpstrFileTitle = szFileTitle; ofn.nMaxFileTitle = sizeof(szFileTitle); ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST; GetOpenFileName(&ofn); IGraphBuilder *pGraph = NULL; IMediaControl *pMediaControl = NULL; IVideoWindow *pVidWin = NULL; IMediaEvent *pEvent; CoInitialize(NULL); // Create the filter graph manager. CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC, IID_IGraphBuilder, (void **)&pGraph); pGraph->QueryInterface(IID_IMediaControl, (void **)&pMediaControl); pGraph->QueryInterface(IID_IVideoWindow, (void **)&pVidWin); pGraph->QueryInterface(IID_IMediaEvent, (void **)&pEvent); // Build the graph. HRESULT a=pGraph->RenderFile(LPCWSTR(ofn.lpstrFile), NULL); //Set the video window. pVidWin->put_WindowStyle(WS_BORDER|WS_SIZEBOX); pVidWin->put_WindowStyle(WS_POPUPWINDOW|WS_BORDER|WS_SIZEBOX); pVidWin->SetWindowPosition(0, 0, 640,480); // Run the graph. pMediaControl->Run(); long evCode; pEvent->WaitForCompletion(INFINITE, &evCode); // Clean up. pVidWin->put_Owner(NULL); pMediaControl->Release(); pEvent->Release(); pGraph->Release(); pVidWin->Release(); } When i call it it opens the open file window...i open a file , but direct show doesn`t play it . I discovered that the problem is at HRESULT a=pGraph->RenderFile(LPCWSTR(ofn.lpstrFile), NULL); Actualy the hresult error code tells me that the file cannot be found. I concluded that it`s something wrong with the conversion. How must i convert the LPSTR field ofn.lpstrFile to LPCWSTR for the function to work?? Popa Razvan Dragos
Popa Razvan Dragos
CodeMunkie
CodeMunkie
Yes, you must convert the char string to a wide char string. Look at the MultiByteToWideChar function on MSDN to see how this is done.

EDIT: Link for you.


Here is how I used it:
...
char* file_name;
WCHAR capture_file[MAX_PATH];
...
MultiByteToWideChar(CP_ACP, 0, file_name, -1, capture_file, MAX_PATH);

[edited by - CodeMunkie on May 11, 2004 4:51:40 PM]
"When you die, if you get a choice between going to regular heaven or pie heaven, choose pie heaven. It might be a trick, but if it's not, mmmmmmm, boy."
How to Ask Questions the Smart Way.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.