`
isiqi
  • 浏览: 16043536 次
  • 性别: Icon_minigender_1
  • 来自: 济南
社区版块
存档分类
最新评论

windows ce directshow播放视频

阅读更多

The following sample program renders a file named Test.avi inside an application window. For brevity, it omits the following functionality:

  • It does not resize the video window when the parent window is resized. To accomplish this, call IVideoWindow::SetWindowPosition again in response to a WM_SIZE message on the parent window.
  • It performs no error checking.
  • It stretches the video window without regard to the aspect ratio of the source. To determine the aspect ratio, use the IBasicVideo interface.
  • It does not handle end-of-stream events. For information on how to do this, see Responding to Events.
NoteTo make the following code example easier to read, error checking is not included. Do not use this code example in a release configuration unless it you have modified it to include secure error handling.
#include <windows.h>
#include <streams.h>

#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. 

//Attach the video playback window to the desired parent window.

//call the IVideoWindow::put_Owner method and pass it a handle to the owner 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) {

//Before the application exits, it is important that

//you set the visibility of the video window to false.

// Otherwise, a video image remains on the screen

//and the user cannot get rid of it. Then, reset the owner to NULL;

//otherwise, messages are sent to the wrong window, likely causing errors.

pVidWin->put_Visible(OAFALSE); pVidWin->put_Owner(NULL); pMediaControl->Release(); pVidWin->Release(); pGraph->Release(); } // Message handler. long FAR PASCAL WindowProc( HWND hwnd, UINT msg, UINT wParam, LONG lParam) { switch (msg) { case WM_DESTROY: CleanUp(); PostQuitMessage(0); break; default: return (DefWindowProc(hwnd, msg, wParam, lParam)); } return(NULL); } // Main. int PASCAL WinMain( HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR pCmdLine, int nCmdShow ) { MSG msg; WNDCLASS wc; CoInitialize(NULL); ZeroMemory(&wc, sizeof wc); wc.lpfnWndProc = WindowProc; wc.hInstance = hInst; wc.hIcon = LoadIcon( NULL, IDI_APPLICATION ); wc.hCursor = LoadCursor( NULL, IDC_ARROW ); wc.hbrBackground = (HBRUSH)GetStockObject( BLACK_BRUSH ); wc.lpszMenuName = NULL; wc.lpszClassName = CLASSNAME; RegisterClass( &wc ); g_hwnd = CreateWindow( CLASSNAME, "DirectShow Sample", (WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX), CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInst, NULL); ShowWindow( g_hwnd, nCmdShow ); UpdateWindow( g_hwnd ); PlayFile(); while( GetMessage( &msg, NULL, 0, 0 ) ) { TranslateMessage( &msg ); DispatchMessage( &msg ); } CoUninitialize(); return msg.wParam; }

<!-- <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/"> <rdf:Description rdf:about="http://ustcers.com/blogs/devzhao/articles/13033.aspx" dc:identifier="http://ustcers.com/blogs/devzhao/articles/13033.aspx" dc:title="windows ce directshow播放视频" trackback:ping="http://ustcers.com/blogs/trackback.aspx?PostID=13033" /> </rdf:RDF> -->
分享到:
评论

相关推荐

    基于Windows CE系统嵌入式开发教程

    第4章 Windows CE窗口和消息机制 第5章 Windows CE资源与控件编程 第7章 多线程编程 第7章 多线程编程 第8章 文件操作与通信编程 第8章 文件操作与通信编程 第10章 Windows CE系统定制 第11章 Windows CE内核机制 第...

    基于C#的Windows CE程序开发实例教程

    本书以C#语言、Visual 2003为开发环境,深入介绍了Windows CE应用程序开发的实用技术。本书分为基础篇和应用篇两部分。基础篇主要介绍了Windows CE概述、C#程序设计基础、XML基础、SQL CE数据库。应用篇主要通过4个...

    windows ce 6.0 截图软件2

    1.该工具可以在PC端快速的启动Windows CE上面的程序(确保你的电脑上已经装了同步软件ActiveSync,Win7的同步软件是Windows Mobile) 2. 在电脑上打开WceUiLauncher,浏览找到要启动的windows CE的应用程序,然后点...

    WINDOWS CE 6.0开发者参考.part01.rar

    1.1 windows ce标准windows的差别 1.1.1 windows ce和标准windows的差别 1.1.2 资源有限的windows ce设备 1.1.3 unicode编码 1.1.4 组件化设计 1.1.5 win32子集 1.2 仍然是windows编程 1.3 第一个windows ce应用程序...

    基于WindowsCE嵌入式视频监控系统的软件设计与实现

    这是我从中国优秀硕士学位论文全文数据库下载的优秀硕士学位论文《基于WindowsCE嵌入式视频监控系统的软件设计与实现》,如果文件格式为*.kdh或者*.nh,请到中国知网下载阅读阅读器CAJViewer, 网址为...

    Windows CE 6.0开发者参考(原书第4版)

    本书包含“windows编程基础”、“windows ce编程”、“高级windows ce”三部分内容,帮助你全面了解windows ce操作系统。同时包含大量windows ce示例程序,所有的例子都是直接用api编写的,教会你如何编写windows ce...

    Windows CE.net 环境安装

    Windows CE.net 环境安装 提示:开发环境安装程序请自行从微软公司购买或其他途径获得,Embest 公司不能收费或免费提供。 安装 Windows CE.net 开发环境比较简单和方便,只要基本按照安装向导的提示一步步操作就可 ...

    WINCE教学示例 Windows ce

    WINCE教学示例 Windowsce实例 wince学习 wince教材WINCE教学示例 Windowsce实例 wince学习 wince教材WINCE教学示例 Windowsce实例 wince学习 wince教材WINCE教学示例 Windowsce实例 wince学习 wince教材WINCE教学...

    Windows CE工程实践完全解析

    《Windows CE工程实践完全解析》讲述了Windows CE操作系统底层驱动软件开发技术。全书共分5篇25章,内容包括开发Windows CE的BootLoader、OAL、显示设备驱动程序、串口驱动程序和PC卡总线接口驱动程序,通过解析和...

    Windows CE嵌入式操作系统原理

    通过本课程的学习,学生将理解嵌入式操作系统的一般性特点,了解Windows CE系统的功能和特性,对Windows CE系统定制开发和应用程序开发有一定的认识。 课程由三部分组成。第一部分介绍嵌入式操作系统的一般性特点。...

    Microsoft Windows CE .NET,Microsoft 已经升级了 Windows CE 的中断体系结构。

    Microsoft Windows CE .NET,Microsoft 已经升级了 Windows CE6.0 的中断体系结构。

    Windows CE 3.0 Application Programming

    Windows CE 3.0 Application Programming presents programming for Pocket PC, handheld PC, and embedded devices. &lt;br&gt;Topics include: &lt;br&gt;Enterprise computing including COM, DCOM, database access ...

    WINDOWS CE实用开发技术.zip.001

    《WINDOWS+CE实用开发技术》完整版电子书pdf版 该书主要涉及WinCE下的驱动开发技术 压缩文件分三部分 需下载完全才能解压: WINDOWS CE实用开发技术.zip.001 WINDOWS CE实用开发技术.zip.002 WINDOWS CE实用开发技术...

    WINDOWS CE 6_0开发者参考.part05.rar

    1.1 windows ce标准windows的差别 1.1.1 windows ce和标准windows的差别 1.1.2 资源有限的windows ce设备 1.1.3 unicode编码 1.1.4 组件化设计 1.1.5 win32子集 1.2 仍然是windows编程 1.3 第一个windows ce应用程序...

    Windows CE5.0 CE 6.0教程:Windows CE6.0的流驱动——I/O驱动

    2004 年开始专业从事 Windows CE 技术开发从 Windows CE 4.2 ,Windows CE 5.0 到,Windows Embedded CE 6.0。2006 年,获推荐参加 Microsoft 全球 Windows CE6.0 讲师培训,经微软考核认证,获得TTT资深讲师资格。

    WINDOWS CE 6.0开发者参考.part11.rar

    1.1 windows ce标准windows的差别 1.1.1 windows ce和标准windows的差别 1.1.2 资源有限的windows ce设备 1.1.3 unicode编码 1.1.4 组件化设计 1.1.5 win32子集 1.2 仍然是windows编程 1.3 第一个windows ce应用程序...

    Windows CE操作系统实验

    安装Windows CE BSP Windows CE内核定制 WINCE和桌面系统通讯 Windows CE应用程序编写 Windows CE驱动程序编写

    WindowsCE下VNC的Server端

    WindowsCE下VNC的Server端,不好早,支持RFB3.8,功能强大,WindowsCE下不可多得的远程桌面

    Windows CE 程序设计

    Windows CE 程序设计的编程,对想学习Windows CE的应该有帮助

    Windows CE 嵌入式开发系列课程视频\(2)使用Embeded Visual C++开发通讯终端及应用实例代码分析

    Windows CE 嵌入式开发系列课程视频\(2)使用Embeded Visual C++开发通讯终端及应用实例代码分析

Global site tag (gtag.js) - Google Analytics