home features api download svn donate license contact
Spanish  
 

How to playing multiples videos in my own window

This example shows how you can playing multiples videos 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
{
// Contains the information of video.
SVideoInfo VideoInfo;
unsigned int videoID;

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

// Retrieves the information of video.
VideoInfo = this -> Video -> GetVideoInfo(videoID);

::SetWindowPos(VideoInfo.hVideo, HWND_TOP,
20, 20, 220, 140, SWP_SHOWWINDOW);

videoID = this -> Video -> LoadVideoFile("video1.mpg");

VideoInfo = this -> Video -> GetVideoInfo(videoID);

::SetWindowPos(VideoInfo.hVideo, HWND_TOP,
260, 20, 220, 140, SWP_SHOWWINDOW);

videoID = this -> Video -> LoadVideoFile("video1.mpg", CE_VIDEO_AUTOPLAY);

VideoInfo = this -> Video -> GetVideoInfo(videoID);

::SetWindowPos(VideoInfo.hVideo, HWND_TOP,
20, 180, 220, 140, SWP_SHOWWINDOW);

videoID = this -> Video -> LoadVideoFile("video1.mpg",
CE_VIDEO_NOPLAYBAR | CE_VIDEO_NOMENU | CE_VIDEO_AUTOPLAY);

VideoInfo = this -> Video -> GetVideoInfo(videoID);

::SetWindowPos(VideoInfo.hVideo, HWND_TOP,
260, 180, 220, 140, SWP_SHOWWINDOW);
};

// 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; }

// --- 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;

::ShowWindow(hWnd, SW_SHOWDEFAULT);

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; }

// --- 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);

// Contains the information of video.
SVideoInfo VideoInfo;
unsigned int videoID;

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

// Retrieves the information of video.
VideoInfo = Video -> GetVideoInfo(videoID);

::SetWindowPos(VideoInfo.hVideo, HWND_TOP,
20, 20, 220, 140, SWP_SHOWWINDOW);

videoID = Video -> LoadVideoFile("video1.mpg");

VideoInfo = Video -> GetVideoInfo(videoID);

::SetWindowPos(VideoInfo.hVideo, HWND_TOP,
260, 20, 220, 140, SWP_SHOWWINDOW);

videoID = Video -> LoadVideoFile("video1.mpg", CE_VIDEO_AUTOPLAY);

VideoInfo = Video -> GetVideoInfo(videoID);

::SetWindowPos(VideoInfo.hVideo, HWND_TOP,
20, 180, 220, 140, SWP_SHOWWINDOW);

videoID = Video -> LoadVideoFile("video1.mpg", CE_VIDEO_NOPLAYBAR |
CE_VIDEO_NOMENU |
CE_VIDEO_AUTOPLAY);

VideoInfo = Video -> GetVideoInfo(videoID);

::SetWindowPos(VideoInfo.hVideo, HWND_TOP,
260, 180, 220, 140, SWP_SHOWWINDOW);

// --- Main loop ---

::MSG msg;

::ShowWindow(hWnd, SW_SHOWDEFAULT);

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