線上訂房服務-台灣趴趴狗聯合訂房中心
發文 回覆 瀏覽次數:2673
推到 Plurk!
推到 Facebook!

請問DirectX 8SDK 裡頭的DirectShow Example...

尚未結案
hao_chih
一般會員


發表:15
回覆:25
積分:18
註冊:2003-09-10

發送簡訊給我
#1 引用回覆 回覆 發表時間:2003-09-24 16:15:33 IP:203.69.xxx.xxx 未訂閱
各位前輩您好~我是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

發送簡訊給我
#2 引用回覆 回覆 發表時間:2003-09-24 16:55:13 IP:210.68.xxx.xxx 未訂閱
引言: 各位前輩您好~我是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

發送簡訊給我
#3 引用回覆 回覆 發表時間:2003-09-24 17:30:15 IP:203.69.xxx.xxx 未訂閱
謝謝板主回應 但因為公司的"裝備"只有 > 請問 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

發送簡訊給我
#4 引用回覆 回覆 發表時間:2003-09-25 22:14:04 IP:61.70.xxx.xxx 未訂閱
     #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

發送簡訊給我
#5 引用回覆 回覆 發表時間:2003-09-26 14:30:07 IP:210.68.xxx.xxx 未訂閱
引言:
     #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

發送簡訊給我
#6 引用回覆 回覆 發表時間:2003-09-26 15:17:52 IP:61.218.xxx.xxx 未訂閱
     #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

發送簡訊給我
#7 引用回覆 回覆 發表時間:2003-09-26 15:25:59 IP:210.68.xxx.xxx 未訂閱
嗯~~~原來這樣改,就可以囉 非常謝謝cmf^^
hao_chih
一般會員


發表:15
回覆:25
積分:18
註冊:2003-09-10

發送簡訊給我
#8 引用回覆 回覆 發表時間:2003-09-30 00:38:53 IP:61.229.xxx.xxx 未訂閱
雖然還是RUN不出來~但也許是環境問題吧 我繼續慢慢試驗好了~ 感謝 >
系統時間:2024-05-06 4:05:59
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!