4 Replies - 487 Views - Last Post: 14 January 2013 - 11:49 AM Rate Topic: -----

#1 sagarsaha128805  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 14-January 13

how to integrate flash video in c programe

Posted 14 January 2013 - 03:13 AM

suppose i have a video which i want to run only when the the question asked is answered right or preset answer prepared for it . does the c compiler needs a separate media player to run the video,
Is This A Good Question/Topic? 0
  • +

Replies To: how to integrate flash video in c programe

#2 Skydiver  Icon User is online

  • Code herder
  • member icon

Reputation: 3652
  • View blog
  • Posts: 11,421
  • Joined: 05-May 12

Re: how to integrate flash video in c programe

Posted 14 January 2013 - 05:57 AM

The compiler compiles code. It doesn't play videos. It will be your code that needs to either implement decoding and displaying the video, or you can pull in an external library to do this, or you can launch another executable to do this.
Was This Post Helpful? 0
  • +
  • -

#3 snoopy11  Icon User is offline

  • Engineering ● Software
  • member icon

Reputation: 837
  • View blog
  • Posts: 2,462
  • Joined: 20-March 10

Re: how to integrate flash video in c programe

Posted 14 January 2013 - 09:40 AM

Hi,

If you are asking can you embed flash videos into a window then yes it can be done
in several ways

here is the easiest way I know of.


#include <windows.h>

#define ID_BUTTON 101
/*  Declare Windows procedure  */
LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);

/*  Make the class name into a global variable  */
char szClassName[ ] = "Flash Video App";

int WINAPI WinMain (HINSTANCE hThisInstance,
	HINSTANCE hPrevInstance,
	LPSTR lpszArgument,
	int nCmdShow)
{
	HWND hwnd;               /* This is the handle for our window */
	MSG messages;            /* Here messages to the application are saved */
	WNDCLASSEX wincl;        /* Data structure for the windowclass */

	/* The Window structure */
	wincl.hInstance = hThisInstance;
	wincl.lpszClassName = szClassName;
	wincl.lpfnWndProc = WindowProcedure;      /* This function is called by windows */
	wincl.style = CS_DBLCLKS;                 /* Catch double-clicks */
	wincl.cbSize = sizeof (WNDCLASSEX);

	/* Use default icon and mouse-pointer */
	wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION);
	wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
	wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
	wincl.lpszMenuName = NULL;                 /* No menu */
	wincl.cbClsExtra = 0;                      /* No extra bytes after the window class */
	wincl.cbWndExtra = 0;                      /* structure or the window instance */
	/* Use Windows's default colour as the background of the window */
	wincl.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);
	/* Register the window class, and if it fails quit the program */
	if (!RegisterClassEx (&wincl))
		return 0;

	/* The class is registered, let's create the program*/
	hwnd = CreateWindowEx (
		0,                   /* Extended possibilites for variation */
		szClassName,         /* Classname */
		szClassName,       /* Title Text */
		WS_OVERLAPPEDWINDOW, /* default window */
		CW_USEDEFAULT,       /* Windows decides the position */
		CW_USEDEFAULT,       /* where the window ends up on the screen */
		544,                 /* The programs width */
		375,                 /* and height in pixels */
		HWND_DESKTOP,        /* The window is a child-window to desktop */
		NULL,                /* No menu */
		hThisInstance,       /* Program Instance handler */
		NULL                 /* No Window Creation data */
		);

	/* Make the window visible on the screen */
	ShowWindow (hwnd, nCmdShow);

	/* Run the message loop. It will run until GetMessage() returns 0 */
	while (GetMessage (&messages, NULL, 0, 0))
	{
		/* Translate virtual-key messages into character messages */
		TranslateMessage(&messages);
		/* Send message to WindowProcedure */
		DispatchMessage(&messages);
	}

	/* The program return-value is 0 - The value that PostQuitMessage() gave */
	return messages.wParam;
}


/*  This function is called by the Windows function DispatchMessage()  */

LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{

	static HWND hwndButton;
	static HWND flash;

	WINDOWPLACEMENT place;

	switch (message)                  /* handle the messages */
	{
	case WM_CREATE:

		{
			hwndButton = CreateWindowEx(0,                    /* more or ''extended'' styles */
				TEXT("BUTTON"),                         /* GUI ''class'' to create */
				TEXT("Push Me"),                        /* GUI caption */
				WS_CHILD|WS_VISIBLE|BS_DEFPUSHBUTTON,   /* control styles separated by | */
				10,                                     /* LEFT POSITION (Position from left) */
				280,                                     /* TOP POSITION  (Position from Top) */
				100,                                    /* WIDTH OF CONTROL */
				30,                                     /* HEIGHT OF CONTROL */
				hwnd,                                   /* Parent window handle */
				(HMENU)ID_BUTTON,                        /* control''s ID for WM_COMMAND */
				NULL,                                /* application instance */
				NULL);

			/* application instance */



			return  0;
		}

	case WM_MOVE:
		{
			GetWindowPlacement(hwnd,&place);
			MoveWindow(flash,place.rcNormalPosition.left+50,place.rcNormalPosition.top+50,200,200,false);
			return 0;
		}
	case WM_SIZE:
		{
			GetWindowPlacement(hwnd,&place);
			MoveWindow(flash,place.rcNormalPosition.left+50,place.rcNormalPosition.top+50,200,200,false);
			return 0;
		}
	case WM_COMMAND:
		{
			switch (wParam)
			{
			case ID_BUTTON:
				{

					GetWindowPlacement(hwnd,&place);
					void* init = GetProcAddress(LoadLibrary("atl"),"AtlAxWinInit"); 
					_asm call init;
					flash = CreateWindow("AtlAxWin", "C:\\Wildlife.swf", WS_VISIBLE|WS_POPUP,place.rcNormalPosition.left+50,place.rcNormalPosition.top+50,200,200,hwnd,0,0,0);






					break;
				}

				break;
			}
			return 0;
		}





	case WM_DESTROY:
		PostQuitMessage (0);       /* send a WM_QUIT to the message queue */
		break;
	default:                      /* for messages that we don't deal with */
		return DefWindowProc (hwnd, message, wParam, lParam);
	}

	return 0;
}



You will have to change C:\\Wildlife.swf to the path of your flash video but apart from that your good to go,
Unfortunately Wildlife.swf is too big to attach. Even though its only 30 seconds long.
It can however be downloaded from here

Wildlife.swf
Snoopy.
Was This Post Helpful? 1
  • +
  • -

#4 Skydiver  Icon User is online

  • Code herder
  • member icon

Reputation: 3652
  • View blog
  • Posts: 11,421
  • Joined: 05-May 12

Re: how to integrate flash video in c programe

Posted 14 January 2013 - 10:22 AM

Since the code above is dependent on ATL to work, you might as well include and link in ATL, instead of dynamically loading ATL. Overall, though, still a good way to quickly host an ActiveX window in which to try to play a video in.
Was This Post Helpful? 0
  • +
  • -

#5 snoopy11  Icon User is offline

  • Engineering ● Software
  • member icon

Reputation: 837
  • View blog
  • Posts: 2,462
  • Joined: 20-March 10

Re: how to integrate flash video in c programe

Posted 14 January 2013 - 11:49 AM

Hi,

Well not all compilers have those libs or headers,

I was just trying to be as cross compiler as possible.

in my own weird ass way.....

As I said there are various ways to do this but this is the easiest way I have come across.

Snoopy.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1