Re: Video Streaming for MPEG file

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



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, &param1, &param2, 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



.



Relevant Pages

  • Re: Gray out a system tray menu entry.
    ... system tray icons currently running on my box. ... WPARAM wParam, LPARAM lParam) ... // The option here is to maintain a list of all TrayIcon windows, ...
    (microsoft.public.vc.mfc)
  • Re: How to trap a windows message?
    ... As you specifically asked about to get the message in the presenter: Only views can recieve Windows Messages - they don't have to be visible but they have to exist. ... wmuFooBarMessage: message wParam: wParam lParam: lParam ...
    (comp.lang.smalltalk.dolphin)
  • Re: WM_MENUCOMMAND in Windows 98 lParam not handle
    ... WPARAM wParam ... LPARAM lParam; ... Windows 98/Me: The high word is the zero-based index of the item ... > selection is made. ...
    (microsoft.public.win32.programmer.ui)
  • Re: long, LONG anf LPARAM
    ... For the current definitions of the LONG and LPARAM typedefs, ... Windows Data Types ... and contrast it with WPARAM. ... be compatible with the data model MS has defined for Windows.) ...
    (microsoft.public.vc.mfc)
  • Re: WinCE 6.0 BSP (CEPC) for Virtual PC
    ... framework does not run on Windows CE. ... application developers don't need Platform Builder. ... generated an OS image and the corresponding emulator image, ... Install VS2005 Pro ...
    (microsoft.public.windowsce.embedded)