Re: Video Streaming for MPEG file
- From: "Brian Burgess" <bburgess66@xxxxxxxxxxx>
- Date: Sun, 12 Feb 2006 10:36:39 +0800
ah well .. your code looks standard .. so it appears (I guess) that WM5 as a
platform does not include it. And, I dont have Platform Builder, nor do I
(to my knowledge) have the resources to get it. Guess most of us are out
of luck.
:-(
Thx
-B
"smartslack" <navin.salunke@xxxxxxxxx> wrote in message
news:1139671504.844597.207150@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
To make this successful your OS should have "directshow". For that you
have to use Platform Builder. Design your own OS to embedded windows
media player and before making SDK confirm that weather you would add
Directshow or not.once you make SDK successfully.Run the setup to use
it.
Now, In coding side. I've used EVC++ as a developement tools. Just
create and empty project. chosing everything default for "Windows CE
Application". Add one item to the menu like "Open file". and in the
code do following changes (or copy paste this code.) by appying your
logic....;) No need to give more stress to your mind...
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM
lParam)
{
HDC hdc;
int wmId, wmEvent;
PAINTSTRUCT ps;
TCHAR szHello[MAX_LOADSTRING];
switch (message)
{
case WM_COMMAND:
wmId = LOWORD(wParam);
wmEvent = HIWORD(wParam);
// Parse the menu selections:
switch (wmId)
{
case IDM_HELP_ABOUT:
DialogBox(hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)About);
break;
case IDM_FILE_EXIT:
DestroyWindow(hWnd);
break;
case IDD_OPEN:
PlayFile(); // Here we are calling the function that we
are going to add
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
break;
case WM_GRAPHNOTIFY: //This
is one more event you have to add
HandleEvent();
break;
case WM_CREATE:
hwndCB = CommandBar_Create(hInst, hWnd, 1);
CommandBar_InsertMenubar(hwndCB, hInst, IDM_MENU, 0);
CommandBar_AddAdornments(hwndCB, 0, 0);
break;
case WM_PAINT:
RECT rt;
hdc = BeginPaint(hWnd, &ps);
GetClientRect(hWnd, &rt);
LoadString(hInst, IDS_HELLO, szHello, MAX_LOADSTRING);
DrawText(hdc, szHello, _tcslen(szHello), &rt,
DT_SINGLELINE | DT_VCENTER | DT_CENTER);
EndPaint(hWnd, &ps);
break;
case WM_DESTROY:
CommandBar_Destroy(hwndCB);
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
return 0;
}
void PlayFile(void)
{
// Create the filter graph manager and render the file.
HRESULT hr;
hr = CoInitialize(NULL);
hr=CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC,
IID_IGraphBuilder, (void **)&pGraph);
// Filenames on Windows CE start with a \\ instead of a drive
letter.
pGraph->RenderFile(L"\\windows\\movie.wmv", NULL);
// Specify the owner window.
IVideoWindow *pVidWin = NULL;
pGraph->QueryInterface(IID_IVideoWindow, (void **)&pVidWin);
pVidWin->put_Owner((OAHWND)g_hwnd);
pVidWin->put_WindowStyle( WS_CHILD | WS_CLIPSIBLINGS);
// Set the owner window to receive event notices.
pGraph->QueryInterface(IID_IMediaEventEx, (void **)&pEvent);
pEvent->SetNotifyWindow((OAHWND)g_hwnd, WM_GRAPHNOTIFY, 0);
// Run the graph.
pGraph->QueryInterface(IID_IMediaControl, (void **)&pMediaControl);
pMediaControl->Run();
}
void CleanUp(void)
{
IVideoWindow *pVidWin = NULL;
pGraph->QueryInterface(IID_IVideoWindow, (void **)&pVidWin);
pVidWin->put_Visible(OAFALSE);
pVidWin->put_Owner(NULL);
// Stop the graph.
pMediaControl->Stop();
long evCode;
pEvent->WaitForCompletion(INFINITE, &evCode);
pMediaControl->Release();
pEvent->Release();
pGraph->Release();
PostQuitMessage(0);
}
void HandleEvent()
{
long evCode, param1, param2;
HRESULT hr;
while (hr = pEvent->GetEvent(&evCode, ¶m1, ¶m2, 0),
SUCCEEDED(hr))
{
hr = pEvent->FreeEventParams(evCode, param1, param2);
if ((EC_COMPLETE == evCode) || (EC_USERABORT == evCode))
{
CleanUp();
break;
}
}
}
Add following at the top. of code in same file
#include <commctrl.h>
#include <windows.h>
#include <streams.h>
#define WM_GRAPHNOTIFY WM_APP + 1
#define CLASSNAME "EventNotify"
#define MAX_LOADSTRING 100
IGraphBuilder *pGraph = NULL;
IMediaControl *pMediaControl = NULL;
IMediaEventEx *pEvent = NULL;
HWND g_hwnd;
(these are the headers and declaration.)
compile and run the appplication...
it will show you menu bar with Hello...
just click on file in Menu and then open
before that check weather you have file on given specific path or not..
other wise it won't give any error.
these functions I got from MSDN help website without any exception
handling...( it is the second phase when we are in research and
devlopment right...;)...
if you want you can ask me to my personal mail id...
Best of luck..
Navin
.
- Follow-Ups:
- Re: Video Streaming for MPEG file
- From: smartslack
- Re: Video Streaming for MPEG file
- References:
- Video Streaming for MPEG file
- From: smartslack
- Re: Video Streaming for MPEG file
- From: Brian Burgess
- Re: Video Streaming for MPEG file
- From: smartslack
- Video Streaming for MPEG file
- Prev by Date: Re: MFC and vertical blank
- Next by Date: Re: Explicit loading does not work
- Previous by thread: Re: Video Streaming for MPEG file
- Next by thread: Re: Video Streaming for MPEG file
- Index(es):
Relevant Pages
|