1 #include <windows.h>
2 #include <stdio.h>
3 #include <stdlib.h>
4 #include <vlc/vlc.h>
5 
6 extern HINSTANCE hInst;
7 
WndProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam)8 LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
9 {
10     switch(msg)
11     {
12         case WM_CLOSE:
13             DestroyWindow(hwnd);
14         break;
15         case WM_DESTROY:
16             PostQuitMessage(0);
17         break;
18         default:
19             return DefWindowProc(hwnd, msg, wParam, lParam);
20     }
21     return 0;
22 }
23 
show_vlc(void * data)24 int __stdcall show_vlc(void *data)
25 {
26      libvlc_instance_t * inst;
27      libvlc_media_player_t *mp;
28      libvlc_media_t *m;
29 	int rc;
30 	HANDLE w;
31 	WNDCLASSEX wc;
32 
33      /* Load the VLC engine */
34      inst = libvlc_new (0, NULL);
35 
36      /* Create a new item */
37      m = libvlc_media_new_path (inst, "C:\\Temp\\[001_1-01] Broken Bow (Part 1).mpg");
38 
39      /* Create a media player playing environement */
40      mp = libvlc_media_player_new_from_media (m);
41 
42      /* No need to keep the media now */
43      libvlc_media_release (m);
44 
45 
46 	//Step 1: Registering the Window Class
47 	wc.cbSize        = sizeof(WNDCLASSEX);
48 	wc.style         = 0;
49 	wc.lpfnWndProc   = WndProc;
50 	wc.cbClsExtra    = 0;
51 	wc.cbWndExtra    = 0;
52 	wc.hInstance     = hInst;
53 	wc.hIcon         = LoadIcon(NULL, IDI_APPLICATION);
54 	wc.hCursor       = LoadCursor(NULL, IDC_ARROW);
55 	wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
56 	wc.lpszMenuName  = NULL;
57 	wc.lpszClassName = L"myclassstuff";
58 	wc.hIconSm       = LoadIcon(NULL, IDI_APPLICATION);
59 
60 	if(!RegisterClassEx(&wc))
61 	{
62 		MessageBox(NULL, L"Window Registration Failed!", L"Error!", MB_ICONEXCLAMATION | MB_OK);
63 		return 0;
64 	}
65 
66 	w = CreateWindow(L"myclassstuff", L"VLC Window", WS_OVERLAPPEDWINDOW, 50, 50, 400, 400, NULL, NULL, hInst, NULL);
67 
68 	if (!w)
69 	{
70 		DWORD d = GetLastError();
71 		printf ("===================== %08x ==============\n", d);
72 
73 	}
74 
75 //	libvlc_media_player_set_hwnd (mp, w);
76 
77 //	ShowWindow(w, SW_SHOW);
78 //	UpdateWindow(w);
79 
80 #if 0
81      /* This is a non working code that show how to hooks into a window,
82       * if we have a window around */
83       libvlc_media_player_set_xdrawable (mp, xdrawable);
84      /* or on windows */
85      /* or on mac os */
86       libvlc_media_player_set_nsobject (mp, view);
87 #endif
88 
89      /* play the media_player */
90      rc = libvlc_media_player_play (mp);
91 
92      Sleep (60000); /* Let it play a bit */
93 
94      /* Stop playing */
95      libvlc_media_player_stop (mp);
96 
97      /* Free the media_player */
98      libvlc_media_player_release (mp);
99 
100      libvlc_release (inst);
101 
102      return 0;
103 }
104