hao_chih
一般會員
發表:15 回覆:25 積分:18 註冊:2003-09-10
發送簡訊給我
|
各位前輩您好~我是BCB的初學者~想學一些有關於用DirectShow撥放影片的功能
請問一下,有關於DirectX 8SDK 裡頭的DirectShow Example...
也找了站內很多前輩的文章,目前DirectShow的範例已經可以LINK沒問題了
我是將下面main的函式內容拷貝到Button_Click事件裡頭~
結果完全沒反應就結束了,但也確定有執行到.. 因為我是初學所以還有蠻多方面不懂,請問各位先進以下這個範例要怎樣才能正確呢?
還是有些地方還需要設定或改的地方? 範例的原始檔案1 How To Play a File
影片路徑有換
#include
void main(void)
{
IGraphBuilder *pGraph;
IMediaControl *pMediaControl;
IMediaEvent *pEvent;
CoInitialize(NULL);
// Create the filter graph manager and query for interfaces.
CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER,
IID_IGraphBuilder, (void **)&pGraph);
pGraph->QueryInterface(IID_IMediaControl, (void **)&pMediaControl);
pGraph->QueryInterface(IID_IMediaEvent, (void **)&pEvent); // Build the graph. IMPORTANT: Change string to a file on your system.
pGraph->RenderFile(L"C:\\Example.avi", NULL); // Run the graph.
pMediaControl->Run(); // Wait for completion.
long evCode;
pEvent->WaitForCompletion(INFINITE, &evCode); // Clean up.
pMediaControl->Release();
pEvent->Release();
pGraph->Release();
CoUninitialize();
} 在範例檔案2(下一個範例)Setting the Video Window 有加了兩行
pVidWin->put_Owner((OAHWND)g_hwnd);
pVidWin->put_WindowStyle(WS_CHILD | WS_CLIPSIBLINGS);
是不是Handle的問題呢?
|
JerryKuo
版主
發表:42 回覆:571 積分:322 註冊:2003-03-10
發送簡訊給我
|
引言:
各位前輩您好~我是BCB的初學者~想學一些有關於用DirectShow撥放影片的功能
請問一下,有關於DirectX 8SDK 裡頭的DirectShow Example...
也找了站內很多前輩的文章,目前DirectShow的範例已經可以LINK沒問題了
我是將下面main的函式內容拷貝到Button_Click事件裡頭~
結果完全沒反應就結束了,但也確定有執行到.. 因為我是初學所以還有蠻多方面不懂,請問各位先進以下這個範例要怎樣才能正確呢?
還是有些地方還需要設定或改的地方? 在範例檔案2(下一個範例)Setting the Video Window 有加了兩行
pVidWin->put_Owner((OAHWND)g_hwnd);
pVidWin->put_WindowStyle(WS_CHILD | WS_CLIPSIBLINGS);
是不是Handle的問題呢?
這個程式,我有試過,不過這好像是給visual c 看的,我試了很久都不會動
因為他不知道要顯示在哪裡,沒有元件顯示。
如果不嫌麻煩的話,你可以下載DirectX 9的DSPACK,裡面Demos\BCB6\有一個
PlayWin的範例,跟你用的很類似,我試過可以用,
下載網址http://www.progdigy.com
但必須加裝directshow的元件。安裝方法可參考本站文章
http://delphi.ktop.com.tw/topic.php?TOPIC_ID=37755
|
hao_chih
一般會員
發表:15 回覆:25 積分:18 註冊:2003-09-10
發送簡訊給我
|
謝謝板主回應
但因為公司的"裝備"只有 > 請問 class="code">
#include
#include #define CLASSNAME "VideoWindow" IGraphBuilder *pGraph = NULL;
IMediaControl *pMediaControl = NULL;
IVideoWindow *pVidWin = NULL;
HWND g_hwnd; void PlayFile(void)
{
// 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); // Build the graph.
pGraph->RenderFile(L"Test.avi", NULL); //Set the video window.
pVidWin->put_Owner((OAHWND)g_hwnd);
pVidWin->put_WindowStyle(WS_CHILD | WS_CLIPSIBLINGS); RECT grc;
GetClientRect(g_hwnd, &grc);
pVidWin->SetWindowPosition(0, 0, grc.right, grc.bottom); // Run the graph.
pMediaControl->Run();
} void CleanUp(void)
{
pVidWin->put_Visible(OAFALSE);
pVidWin->put_Owner(NULL);
pMediaControl->Release();
pVidWin->Release();
pGraph->Release();
} 這個範例有設定撥出視窗的hwnd,但執行可能會出錯~
原因是他少了第一個範例的CoInitialize(NULL);
把它加進PlayFile的最上面就可以RUN囉~
不過....一樣沒反應
|
cmf
尊榮會員
發表:84 回覆:918 積分:1032 註冊:2002-06-26
發送簡訊給我
|
#include
#include #define CLASSNAME "VideoWindow" IGraphBuilder *pGraph = NULL;
IMediaControl *pMediaControl = NULL;
IVideoWindow *pVidWin = NULL;
HWND g_hwnd; void PlayFile(void)
{
// 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); // Build the graph.
pGraph->RenderFile(L"Test.avi", NULL); //Set the video window.
g_hwnd=Form1->Handle;
pVidWin->put_Owner((OAHWND)g_hwnd);
pVidWin->put_WindowStyle(WS_CHILD | WS_CLIPSIBLINGS); RECT grc;
GetClientRect(g_hwnd, &grc);
pVidWin->SetWindowPosition(0, 0, grc.right, grc.bottom); // Run the graph.
pMediaControl->Run();
} void CleanUp(void)
{
pVidWin->put_Visible(OAFALSE);
pVidWin->put_Owner(NULL);
pMediaControl->Release();
pVidWin->Release();
pGraph->Release();
}
------ ︿︿
|
JerryKuo
版主
發表:42 回覆:571 積分:322 註冊:2003-03-10
發送簡訊給我
|
引言:
#include
#include #define CLASSNAME "VideoWindow" IGraphBuilder *pGraph = NULL;
IMediaControl *pMediaControl = NULL;
IVideoWindow *pVidWin = NULL;
HWND g_hwnd; void PlayFile(void)
{
// 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); // Build the graph.
pGraph->RenderFile(L"Test.avi", NULL); //Set the video window.
g_hwnd=Form1->Handle;
pVidWin->put_Owner((OAHWND)g_hwnd);
pVidWin->put_WindowStyle(WS_CHILD | WS_CLIPSIBLINGS); RECT grc;
GetClientRect(g_hwnd, &grc);
pVidWin->SetWindowPosition(0, 0, grc.right, grc.bottom); // Run the graph.
pMediaControl->Run();
} void CleanUp(void)
{
pVidWin->put_Visible(OAFALSE);
pVidWin->put_Owner(NULL);
pMediaControl->Release();
pVidWin->Release();
pGraph->Release();
}
綠色這一行compiler會有問題,我現在是把他mark掉,在pVidWin->SetWindowPosition()這個涵數,自己填大小就可以work..ok! 我是用bcb6.0,只有加裝dspack,其他都沒裝,綠色這一行,要如何更改呢?
|
cmf
尊榮會員
發表:84 回覆:918 積分:1032 註冊:2002-06-26
發送簡訊給我
|
#include
#include #define CLASSNAME "VideoWindow" IGraphBuilder *pGraph = NULL;
IMediaControl *pMediaControl = NULL;
IVideoWindow *pVidWin = NULL;
HWND g_hwnd; void PlayFile(void)
{
// 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); // Build the graph.
pGraph->RenderFile(L"Test.avi", NULL); //Set the video window.
g_hwnd=Form1->Handle;
pVidWin->put_Owner((OAHWND)g_hwnd);
pVidWin->put_WindowStyle(WS_CHILD | WS_CLIPSIBLINGS); TRECT grc;
grc=Form1->ClientRect; pVidWin->SetWindowPosition(0, 0, grc.right, grc.bottom); // Run the graph.
pMediaControl->Run();
} void CleanUp(void)
{
pVidWin->put_Visible(OAFALSE);
pVidWin->put_Owner(NULL);
pMediaControl->Release();
pVidWin->Release();
pGraph->Release();
}
發表人 - cmf 於 2003/09/26 15:19:56
------ ︿︿
|
JerryKuo
版主
發表:42 回覆:571 積分:322 註冊:2003-03-10
發送簡訊給我
|
|
hao_chih
一般會員
發表:15 回覆:25 積分:18 註冊:2003-09-10
發送簡訊給我
|
雖然還是RUN不出來~但也許是環境問題吧
我繼續慢慢試驗好了~
感謝 >
|