home features api download svn donate license contact
Spanish  
 

How to playing a video in my own window

This example shows how you can playing a video in your own window.

(without the VideoCore Player)

 
 

Example using the implementation class

#include <windows.h>
// We are including the main header file it that contains
// the implementation class.

#include <ceVideoCoreImpl.h>
#include <cstdio> // For printf.

// We are using the namespace "ce" (CorEngine) by default (Optional).
using namespace ce;

// We are creating our own manager class, inheriting the implementation class.
class CVideoManager : public IVideoManagerImpl<CVideoManager>
{
public:

inline void Example(void) const
{
// Load a video file.
this -> Video -> LoadVideoFile("video1.mpg",
CE_VIDEO_NOPLAYBAR | CE_VIDEO_NOMENU | CE_VIDEO_AUTOPLAY);
};

// Operator -> (Optional).
const CVideoManager* operator -> (void) const
{ return this; };

};

::LRESULT CALLBACK WindowProcedure(::HWND, ::UINT, ::WPARAM, ::LPARAM);

int main(int argc, char **argv)
{
// --- Create a window ---

::WNDCLASSEX wincl;
::ZeroMemory(&wincl, sizeof(::WNDCLASSEX));

wincl.cbSize = sizeof(::WNDCLASSEX);
wincl.hInstance = ::GetModuleHandle(NULL);
wincl.lpszClassName = "VideoCoreExample";
wincl.hbrBackground = (::HBRUSH) COLOR_BACKGROUND;
wincl.lpfnWndProc = WindowProcedure;

if (!::RegisterClassEx(&wincl)) return 1;

::HWND hWnd = ::CreateWindowEx(0, wincl.lpszClassName, "VideoCore Example",
WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN,
CW_USEDEFAULT, CW_USEDEFAULT, 512, 384,
HWND_DESKTOP, NULL, wincl.hInstance, NULL);

if (hWnd == NULL)
{ ::UnregisterClass(wincl.lpszClassName, wincl.hInstance); return 1; }

::ShowWindow(hWnd, SW_SHOWDEFAULT);

// --- VideoCore ---

// We are creating a instance of our manager class.

const CVideoManager Video;

// Verify the integrity of the manager class (Optional).
if (Video -> VerifyVideoManager() == 0)
{ ::UnregisterClass(wincl.lpszClassName, wincl.hInstance); return 1; }

// This method registers a window for subsequent use in calls
// to the CreateVideoWindow() method.

Video -> RegisterVideoWindow(wincl.hInstance, hWnd);

Video -> Example();

// --- Main loop ---

::MSG msg;
while (!::GetMessage(&msg, NULL, 0, 0) < 1)
{
::TranslateMessage(&msg);
::DispatchMessage(&msg);
}

// Release all the videos (Optional).
Video -> ReleaseAllVideos();

::UnregisterClass(wincl.lpszClassName, wincl.hInstance);

return 0;
}

::LRESULT CALLBACK
WindowProcedure(::HWND hWnd, ::UINT message, ::WPARAM wParam, ::LPARAM lParam)
{
switch (message)
{
case WM_DESTROY: ::PostQuitMessage(0); break;
default: return ::DefWindowProc(hWnd, message, wParam, lParam);
} return 0;
}
 

Example using the interface class

#include <windows.h>
// We are including the main header file it that contains the interface class.
#include <ceVideoCore.h>
#include <cstdio> // For printf.

// We are using the namespace "ce" (CorEngine) by default (Optional).
using namespace ce;

::LRESULT CALLBACK WindowProcedure(::HWND, ::UINT, ::WPARAM, ::LPARAM);

int main(int argc, char **argv)
{
// --- Create a window ---

::WNDCLASSEX wincl;
::ZeroMemory(&wincl, sizeof(::WNDCLASSEX));

wincl.cbSize = sizeof(::WNDCLASSEX);
wincl.hInstance = ::GetModuleHandle(NULL);
wincl.lpszClassName = "VideoCoreExample";
wincl.hbrBackground = (::HBRUSH) COLOR_BACKGROUND;
wincl.lpfnWndProc = WindowProcedure;

if (!::RegisterClassEx(&wincl)) return 1;

::HWND hWnd = ::CreateWindowEx(0, wincl.lpszClassName, "VideoCore Example",
WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN,
CW_USEDEFAULT, CW_USEDEFAULT, 512, 384,
HWND_DESKTOP, NULL, wincl.hInstance, NULL);

if (hWnd == NULL)
{ ::UnregisterClass(wincl.lpszClassName, wincl.hInstance); return 1; }

::ShowWindow(hWnd, SW_SHOWDEFAULT);

// --- VideoCore ---

// We are creating a instance of the manager class.

IVideoManager *Video = CreateVideoManager();
if (Video == NULL)
{ ::UnregisterClass(wincl.lpszClassName, wincl.hInstance); return 1; }

// This method registers a window for subsequent use in calls
// to the CreateVideoWindow() method.

Video -> RegisterVideoWindow(wincl.hInstance, hWnd);

// Load a video file.
Video -> LoadVideoFile("video1.mpg", CE_VIDEO_NOPLAYBAR |
CE_VIDEO_NOMENU |
CE_VIDEO_AUTOPLAY);

// --- Main loop ---

::MSG msg;
while (!::GetMessage(&msg, NULL, 0, 0) < 1)
{
::TranslateMessage(&msg);
::DispatchMessage(&msg);
}

// Release all the videos (Optional).
Video -> ReleaseAllVideos();

// Release the instance of the class manager.
DestroyVideoManager(&Video);

::UnregisterClass(wincl.lpszClassName, wincl.hInstance);

return 0;
}

::LRESULT CALLBACK
WindowProcedure(::HWND hWnd, ::UINT message, ::WPARAM wParam, ::LPARAM lParam)
{
switch (message)
{
case WM_DESTROY: ::PostQuitMessage(0); break;
default: return ::DefWindowProc(hWnd, message, wParam, lParam);
} return 0;
}
 
 
 SourceForge.net
 
   Creative Commons License   Except where otherwise noted, content on this site is
  licensed under a Creative Commons Attribution 3.0 License